Last active
July 25, 2016 05:25
-
-
Save cinohub/6df10643153d7ae161d8ea3c8b71c9e9 to your computer and use it in GitHub Desktop.
Get list installed app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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