Trying to get a list of all of the installed apps on the phone. I tried to do this (I took the code from this post and improve it):
PackageManager pm = getPackageManager();
List<ApplicationInfo> apps = pm.getInstalledApplications(0);
List<ApplicationInfo> installedApps = new ArrayList<ApplicationInfo>();
int myFlags = ApplicationInfo.CATEGORY_AUDIO |
ApplicationInfo.CATEGORY_GAME |
ApplicationInfo.CATEGORY_IMAGE |
ApplicationInfo.CATEGORY_MAPS |
ApplicationInfo.CATEGORY_NEWS |
ApplicationInfo.CATEGORY_SOCIAL |
ApplicationInfo.CATEGORY_VIDEO |
ApplicationInfo.CATEGORY_UNDEFINED |
ApplicationInfo.CATEGORY_PRODUCTIVITY;
for(ApplicationInfo app : apps)
{
if ( (app.flags & myFlags) != 0 && app.icon != 0) {
installedApps.add(app);
}
What I'm trying to get is if the app has an icon, which means it appears in the launcher, and if so I add it to my list.
For some reason some apps are missing like "YouTube" and "YT Music" and I don't understand what should I change in order to identify these applications.