Wednesday, 28 August 2013

packageManager.getInstalledPackages(0) doesn't return all apps

packageManager.getInstalledPackages(0) doesn't return all apps

I'm using
PackageManager packageManager = getPackageManager();
List<PackageInfo> mApps = packageManager.getInstalledPackages(0);
to retrieve a list of all installed apps. However, the list doesn't
contain all installed apps, some (like Twitter, for example) are missing.
To test this, I'm using
int length = mApps.size();
for(int i=0; i<length; i++){
PackageInfo info = mApps.get(i);
Log.i(TAG, "Package: " + info.packageName);
}
com.twitter.android and others aren't among the logged strings, even
though they are installed on the phone.
P.S.: I've also tried
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> mApps =
getPackageManager().queryIntentActivities(mainIntent, 0);
which shows Twitter, but doesn't (obviously) return processes that can't
be launched via the launcher, such as "Download Manager" or "System UI". I
need a method that returns both system apps and third-party apps reliably.

No comments:

Post a Comment