问题描述
我用
PackageManager packageManager = getPackageManager();
List<PackageInfo> mApps = packageManager.getInstalledPackages(0);
检索所有安装的应用程序列表。但是,该列表不包含所有安装的应用程序,有的(如Twitter,例如)失踪。
to retrieve a list of all installed apps. However, the list doesn't contain all installed apps, some (like Twitter, for example) are missing.
要测试这一点,我使用
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
和别人不登录串中的,即使它们在手机上安装。
com.twitter.android
and others aren't among the logged strings, even though they are installed on the phone.
P.S:我也试过
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> mApps = getPackageManager().queryIntentActivities(mainIntent, 0);
这表明Twitter的,但确实无法通过启动器启动不是(显然)回归过程,如下载管理器或系统UI。我需要同时返回系统应用和第三方应用可靠的方法。
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.
推荐答案
这是由在我身边的错误造成的后(错误地打破了为
-loop出某些条件得到满足),因此不会有什么做的软件包管理系统本身或者我打电话的方式。
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.
这篇关于packageManager.getInstalledPackages(0)不返回所有的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!