This is the code that i have at the moment but i still can\'t get a list of all the apps on the phone. Does anyone see what i am doing wrong?
public class G
This is the code I use to list applications:
PackageManager pm = this.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
String activityName = rInfo.activityInfo.name;
List list = pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);
for (ResolveInfo rInfo : list) {
pkg = rInfo.activityInfo.applicationInfo.packageName;
if (pm.getLaunchIntentForPackage(pkg) == null) {
continue;
}
String label = rInfo.activityInfo.applicationInfo.loadLabel(pm).toString();
arrayList.add(new AppEntry(label, activityName, pkg, null));
}
If you later on want to run application only knowing pkg and activityName you can do:
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(pkg, activityname);
ctx.startActivity(intent);