-1

I want to get list of all the apps installed in android phone. By following code I am able to get only user installed apps but I want to get system apps too.

packageManager = getPackageManager();
        List<PackageInfo> packageList = packageManager.getInstalledPackages(packageManager.GET_PERMISSIONS);//PackageManager.GET_META_DATA

    List<PackageInfo> packageList1 = new ArrayList<PackageInfo>();
    PackageManager pm = this.getPackageManager();
    /*To filter out System apps*/
    for(PackageInfo pi : packageList) {
        boolean b = isSystemPackage(pi);
        if(!b) {
            packageList1.add(pi);
        }
    }
    apkList = (ListView) findViewById(R.id.AppList);
    apkList.setAdapter(new ApkAdapter(this, packageList1, packageManager));

    apkList.setOnItemClickListener(this);
}

private boolean isSystemPackage(PackageInfo pkgInfo) {
        return ((pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) ? true
                : false;
    }
Kara
  • 5,650
  • 15
  • 48
  • 55
Jinal Patel
  • 631
  • 4
  • 15

1 Answers1

0

Try this:

final PackageManager pm = getActivity().getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> apps = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);

Hope it will helps you..!

Lokesh
  • 4,952
  • 4
  • 25
  • 43