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 getInstalledApplications but I don't know which flags to add to get the list. Any help would be appreciated.
Edit: Here is an code example of v4_adi's answer.
public static List<String> getAppsFromUnknownSources(Context context)
{
  List<String> apps = new ArrayList<>();
  PackageManager packageManager = context.getPackageManager();
  List<PackageInfo> packList = packageManager.getInstalledPackages(0);
  for (int i = 0; i < packList.size(); i++)
  {
     PackageInfo packInfo = packList.get(i);
     if (packageManager.getInstallerPackageName(packInfo.packageName) == null)
     {
        apps.add(packInfo.packageName);
     }
  }
  return apps;
}
This is a good start, however this also returns a lot off pre-installed Android and Samsung apps. Is there anyway to remove them from the list? I only want user installed apps from unknown sources.
 
     
    