0

Possible Duplicate:
How do I check if an app is a non-system app in Android?

At the moment this code returns everything including system apps like the Android System and clock.

public List<ApplicationInfo> getApps() {
        final PackageManager pm = context.getPackageManager();
        List<ApplicationInfo> packages = pm
                .getInstalledApplications(PackageManager.GET_META_DATA);
        return packages;
    }

How can I differentiate between these and user-installed apps?

Community
  • 1
  • 1
code511788465541441
  • 20,207
  • 61
  • 174
  • 298
  • 2
    http://stackoverflow.com/questions/8784505/how-do-i-check-if-an-app-is-a-non-system-app-in-android – Nermeen Nov 16 '12 at 14:19

1 Answers1

10

Hi you can use the code below

 for(ApplicationInfo app : apps) {
        //checks for flags; if flagged, check if updated system app
        if((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 1) {
            installedApps.add(app);
        //it's a system app, not interested
        } else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
            //Discard this one
        //in this case, it should be a user-installed app
        } else {
            installedApps.add(app);
        }
    }
Talha
  • 12,284
  • 4
  • 46
  • 65