Skip to content

Instantly share code, notes, and snippets.

@cinohub
Last active July 25, 2016 05:25
Show Gist options
  • Save cinohub/6df10643153d7ae161d8ea3c8b71c9e9 to your computer and use it in GitHub Desktop.
Save cinohub/6df10643153d7ae161d8ea3c8b71c9e9 to your computer and use it in GitHub Desktop.
Get list installed app
private List<Application> getInstalledAppList() {
List<Application> listApps = new ArrayList<>();
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = getPackageManager().queryIntentActivities(mainIntent, 0);
// Them vao list
for (Object object : pkgAppsList) {
ResolveInfo info = (ResolveInfo) object;
Drawable icon = getBaseContext().getPackageManager().getApplicationIcon(info.activityInfo.applicationInfo);
String strPackageName = info.activityInfo.applicationInfo.packageName.toString();
final String title = (String) ((info != null) ? getBaseContext().getPackageManager().getApplicationLabel(info.activityInfo.applicationInfo) : "???");
Application app = new Application();
app.setmIcon(icon);
app.setmName(title);
app.setmPackage(strPackageName);
listApps.add(app);
}
return listApps;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment