Skip to content

Instantly share code, notes, and snippets.

@puke3615
Created July 14, 2021 07:52
Show Gist options
  • Save puke3615/81425e57f35ec36cbb4bc6bc9860ae42 to your computer and use it in GitHub Desktop.
Save puke3615/81425e57f35ec36cbb4bc6bc9860ae42 to your computer and use it in GitHub Desktop.
ClassScanner
private static List<Class<?>> scanClass(Context context) throws IOException {
Enumeration<String> entries = new DexFile(context.getPackageCodePath()).entries();
List<Class<?>> result = new ArrayList<>();
while (entries.hasMoreElements()) {
String className = entries.nextElement();
try {
Class<?> type = Class.forName(className);
// do something here
} catch (Throwable t) {
Log.e(TAG, String.format("Load %s failure.", className), t);
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment