尝试检索每个包的所有活动会导致所有活动都为空 ActivityInfo 数组:
List<PackageInfo> packageInfos = mPackageManager.getInstalledPackages(
PackageManager.GET_ACTIVITIES &
PackageManager.GET_SERVICES &
PackageManager.GET_RECEIVERS &
PackageManager.GET_PROVIDERS &
PackageManager.GET_PERMISSIONS);
for (PackageInfo p : packageInfos)
Log.wtf(TAG, p.packageName + ": " + (p.activities == null ? "null" :"not null"));
所有包的p.activities为空。根据https://developer.android.com/reference/android/content/pm/PackageInfo.html#activities它不应该为空,因为设置了 GET_ACTIVITIES 标志。
那么问题出在哪里呢?