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.

有帮助吗?

解决方案

This was caused by an error on my side (erroneously breaking out of the for-loop after a certain condition was met) and thus doesn't have anything to do with the PackageManager itself or the way that I was calling it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top