I need to store all the installed apps icons in an array, and names in another array, so I´ve this code:
List<PackageInfo> apps = getPackageManager().getInstalledPackages(0);
int numberApps = apps.size();
String[] appsNames = new String[numberApps];
Drawable[] appsIcons = new Drawable[numberApps];
for(int i=0;i<apps.size();i++) {
PackageInfo p = apps.get(i);
String pname = p.packageName;
String appname = p.applicationInfo.loadLabel(getPackageManager()).toString();
appsNames[i] = appname;
Drawable appicon = p.applicationInfo.loadIcon(getPackageManager());
appsIcons[i] = appicon;
}
And it works, the problem is that all the apps are displayed, even the system ones, so now i need to change the code for getting just the ones installed or updated by the user. I´ve been searching and I´ve found this and this, but as i´m using a Drawable and string array, and I cannot change that, I don´t know how to make it work. Can someone help me please??