查找 Android 上所有已安装的应用程序,包括 Google 移动服务应用程序

Finding all the installed Apps on Android including Google Mobile Service Apps

这个问题之前有人问过: How to get list of ALL apps (including System Apps)?

然而,当我调用getPackageManager().getInstalledPackages(0)时,它并没有return所有的应用程序。例如,此调用未找到以下应用:com.google.android.music, com.google.android.youtube, com.google.earth, com.google.android.gm.

是否因为它们是 Google 移动服务的一部分?

代码:

public static List<ApplicationInfo> getInstalledAppInfos(Context context) {
    final PackageManager packageManager = context.getPackageManager();
    return packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
}

测试:

List<ApplicationInfo> apps = getInstalledAppInfos(this);
for (int i = 0; i < apps.size(); i++) {
         Log.d(TAG, "App( " + i + ") " + apps.get(i).packageName);
}