4

I am doing the following to get the list of apps and I am only getting apps that were installed but not ALL apps, including system apps.

I have tried the following:

    packageList1 = getPackageManager().getInstalledPackages(PackageManager.GET_META_DATA);

and this:

    packageList1 = getPackageManager().getInstalledPackages(0);

For both cases, I am getting the same list of apps that I have installed on the phone.

user1406716
  • 9,565
  • 22
  • 96
  • 151
  • Are you sure that the list does not contain system apps? Because it should, most likely you are interpreting the data you get wrong. Loop through all the `ApplicationInfos` and the ones that have the flag `FLAG_UPDATED_SYSTEM_APP` or `FLAG_SYSTEM` are system apps. – Xaver Kapeller May 12 '14 at 01:03
  • You are right, i was misunderstanding part of my code (i do some post processing after getting the list) – user1406716 May 12 '14 at 01:10
  • possible duplicate of [How to get all apps installed on android phone](http://stackoverflow.com/questions/5393607/how-to-get-all-apps-installed-on-android-phone) – user1406716 May 12 '14 at 01:12

2 Answers2

10

You are already getting a list of all installed applications including the system apps by calling this:

List<ApplicationInfo> apps = getPackageManager().getInstalledPackages(0);

Those with the flags:

  • ApplicationInfo.FLAG_UPDATED_SYSTEM_APP
  • ApplicationInfo.FLAG_SYSTEM

are system apps. You can check for the flags like this:

List<ApplicationInfo> apps = getPackageManager().getInstalledApplications(0);
for(ApplicationInfo app : apps) {
    if((app.flags & (ApplicationInfo.FLAG_UPDATED_SYSTEM_APP | ApplicationInfo.FLAG_SYSTEM)) > 0) {
        // It is a system app
    } else {
        // It is installed by the user
    }
}
Xaver Kapeller
  • 49,491
  • 11
  • 98
  • 86
0
List<ApplicationInfo> apps = getPackageManager().getInstalledApplications(0);
for(ApplicationInfo app : apps) {
    if((app.flags & (ApplicationInfo.FLAG_UPDATED_SYSTEM_APP | ApplicationInfo.FLAG_SYSTEM)) > 0) {
        // It is a system app
    } else {
        // It is installed by the user
    }
}
Amjad Omari
  • 1,104
  • 3
  • 15
  • 40
guest
  • 9
  • 3