TestErrorInfo.printClass(this, "com.android.bluetooth.opp.Constants");
public static void printClass(Context cc, String clsName) { try { Context c = cc.createPackageContext("com.android.bluetooth", Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); //载入这个类 Class clazz = c.getClassLoader().loadClass(clsName); android.util.Log.w(TestEnv.TAG, "method: " + clazz.getName()); Field[] ff = clazz.getDeclaredFields(); for (Field f : ff) { android.util.Log.w(TestEnv.TAG, "field: " + f.getName()); } } catch (Throwable e) { e.printStackTrace(); } }
蓝牙OPP模块调试技巧
本文介绍了一种用于调试蓝牙OPP模块的方法,通过自定义的printClass函数,可以打印出指定类的所有字段名,有助于开发者理解类的内部结构及进行问题定位。
305

被折叠的 条评论
为什么被折叠?



