Issue
I want to extract all the activities names from an android apk file. Any idea how possibly it can be done?
Thanx Kaps
Solution
You can use the PackageManager method href="http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackageArchiveInfo%28java.lang.String,%20int%29" rel="noreferrer">getPackageArchiveInfo to retrieve the information from an APK file. Assuming your APK lives in the root of your SD card, you can use this code:
String apkPath = Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/MyApp.apk";
PackageManager pm = getPackageManager();
PackageInfo info = pm.getPackageArchiveInfo(apkPath,
PackageManager.GET_ACTIVITIES);
//Log.i("ActivityInfo", "Package name is " + info.packageName);
for (android.content.pm.ActivityInfo a : info.activities) {
Log.i("ActivityInfo", a.name);
}
There is plenty of additional information you can find in the ActivityInfo and PackageInfo objects.
Answered By - David Snabel-Caunt
Answer Checked By - Clifford M. (JavaFixing Volunteer)