0
有谁知道如何获取Android包中的类的列表(从Android应用程序中),或者如何使用可以与Dalvik VM一起使用的反射来检索给定包中的类名?Android - 获取加载的类/反射来获取包中的类?
有谁知道如何获取Android包中的类的列表(从Android应用程序中),或者如何使用可以与Dalvik VM一起使用的反射来检索给定包中的类名?Android - 获取加载的类/反射来获取包中的类?
因此,对于Android,我们可以使用DexFile类来枚举给定APK中的可见类。
try {
DexFile dexFile = new DexFile(new File("/data/app/com.uxpsystems.cepclient-2.apk"));
Enumeration<String> enumeration = dexFile.entries();
if (enumeration.hasMoreElements() == false){
Logger.d(LOG_TAG, "--> Enumeration has no elements");
}
while (enumeration.hasMoreElements()){
String className = enumeration.nextElement();
if (className.substring(0, 18).equals("com.somecompany.aproduct")){
Logger.d(LOG_TAG, "--> Enumeration: " + className);
}else{
// Logger.d(LOG_TAG, "--> Failed match: " + className.substring(0, 18));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
感谢您的分享 – Diljeet