I think that it should be possible to get all the activities from \'third-party\' application, described in the manifest file. I can\'t figure out how.
for example:<
You should be able to do just that using the PackageManager's getPackageArchiveInfo()
using the GET_ACTIVITIES
flag. I have not tried it though
If you have the application context then use this:
private static void listAllActivities(Context context) {
PackageManager pManager = context.getPackageManager();
String packageName = context.getApplicationContext().getPackageName();
try {
ActivityInfo[] list = pManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES).activities;
for (ActivityInfo activityInfo : list) {
Log.d(TAG, "ActivityInfo = " + activityInfo.name);
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
public ActivityInfo[] getActivityList() throws NameNotFoundException {
PackageManager pm = this.getPackageManager();
PackageInfo info = pm.getPackageInfo(getApplicationContext.getPackageName(), PackageManager.GET_ACTIVITIES);
ActivityInfo[] list = info.activities;
return list;
}
Thanks for the answer!
I think I found a solution for listing all the activities in an application too, not the most elegant though...
//the method gets all activities for an application
private void getAppActivities() {
PackageManager pManager = getPackageManager();
Intent startIntent = setStartIntent();
List<ResolveInfo> apps = pManager.queryIntentActivities(startIntent, 0);
int count = apps.size();
for (int i = 0; i < count; i++) {
ResolveInfo info = apps.get(i);
String packageName = info.activityInfo.packageName;
Intent intent = new Intent();
intent.setPackage(packageName);
//activities holds the activities defined in the package
List<ResolveInfo> activities = pManager.queryIntentActivities(intent, 0);
}
}