I asked a similar question to this earlier this week but I\'m still not understanding how to get a list of all installed applications and then pick one to run.
I\'v
I have another solution:
ArrayList myAppsToUpdate;
// How to get the system and the user apps.
public ArrayList getAppsToUpdate() {
PackageManager pm = App.getContext().getPackageManager();
List installedApps = pm.getInstalledApplications(0);
myAppsToUpdate = new ArrayList();
for (ApplicationInfo aInfo : installedApps) {
if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
// System apps
} else {
// Users apps
AppInfo appInfo = new AppInfo();
appInfo.setAppName(aInfo.loadLabel(pm).toString());
appInfo.setPackageName(aInfo.packageName);
appInfo.setLaunchActivity(pm.getLaunchIntentForPackage(aInfo.packageName).toString());
try {
PackageInfo info = pm.getPackageInfo(aInfo.packageName, 0);
appInfo.setVersionName(info.versionName.toString());
appInfo.setVersionCode("" + info.versionCode);
myAppsToUpdate.add(appInfo);
} catch (NameNotFoundException e) {
Log.e("ERROR", "we could not get the user's apps");
}
}
}
return myAppsToUpdate;
}