Skip to content Skip to sidebar Skip to footer

Android Get List Of Non Play Store Apps

As a safety measure I would like to get the list of apps that aren't installed from the Play Store. Is there a way to do this? The packageManager contains a method getInstalledApp

Solution 1:

The following link has answer to your question The PackageManager class supplies the getInstallerPackageName method that will tell you the package name of whatever installed the package you specify. Side-loaded apps will not contain a value.

How to know an application is installed from google play or side-load?

Solution 2:

Originally I thought it would be enough to retrieve the apps that weren't installed via the Google Play Store. Later I found that I also needed to filter out the pre-installed system applications. I found the last part of the puzzle in another post: Get list of Non System Applications

publicstatic List<String> getAppsFromUnknownSources(Context context)
{
  List<String> apps = newArrayList<>();
  PackageManagerpackageManager= context.getPackageManager();
  List<PackageInfo> packList = packageManager.getInstalledPackages(0);
  for (inti=0; i < packList.size(); i++)
  {
     PackageInfopackInfo= packList.get(i);
     booleanhasEmptyInstallerPackageName= packageManager
           .getInstallerPackageName(packageInfo.packageName) == null;
     booleanisUserInstalledApp= (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0;

     if (hasEmptyInstallerPackageName && isUserInstalledApp)
     {
        apps.add(packInfo.packageName);
     }
  }

  return apps;
}

Post a Comment for "Android Get List Of Non Play Store Apps"