3

I'm able to get a list of installed packages using the package manager, but this includes various system packages . Are there any filters i can apply on this list to only show the apps that would show up when bringing up the application list from the home screen?

Mike
  • 33
  • 2

3 Answers3

6
boolean nonSystem = (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0;
yanchenko
  • 56,576
  • 33
  • 147
  • 165
  • 1
    Yeah but that also filters our the Camera application. How do you make it not filter out these types of apps? – Taranasus Sep 12 '11 at 16:28
1

You can use intent filtering to get the application list from the home screen:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> apps = getPackageManager().queryIntentActivities(intent, 0);
chiuki
  • 14,580
  • 4
  • 40
  • 38
0

THE ABOVE ANSWERS WILL NOT WORK IN ALL CASES

If an Application is a non-system application it must have a launch Intent by which it can be launched. If the launch intent is null then its a system App else its a non-system app

Example of System Apps: "com.android.browser.provider", "com.google.android.voicesearch".

For the above apps you will get NULL when you query for launch Intent.

PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for(ApplicationInfo packageInfo:packages){
    if( pm.getLaunchIntentForPackage(packageInfo.packageName) != null ){
                String currAppName = pm.getApplicationLabel(packageInfo).toString();
               //This app is a non-system app
    }
}
Darshan Patel
  • 515
  • 1
  • 8
  • 14