如何获得所有的应用程序(包括系统应用)的名单? [英] How to get list of ALL apps (including System Apps)?
本文介绍了如何获得所有的应用程序(包括系统应用)的名单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我做下面让应用程序列表,我只获得已安装的应用程序,但并非所有的应用,包括系统应用。
I am doing the following to get the list of apps and I am only getting apps that were installed but not ALL apps, including system apps.
我曾尝试以下内容:
packageList1 = getPackageManager().getInstalledPackages(PackageManager.GET_META_DATA);
和这样的:
packageList1 = getPackageManager().getInstalledPackages(0);
有关这两种情况下,我得到了我已经安装在手机上的应用程序相同的列表。
For both cases, I am getting the same list of apps that I have installed on the phone.
推荐答案
您已经获得所有已安装的应用程序的列表,包括通过调用该系统的应用程序:
You are already getting a list of all installed applications including the system apps by calling this:
List<ApplicationInfo> apps = getPackageManager().getInstalledPackages(0);
那些具有标志:
-
ApplicationInfo.FLAG_UPDATED_SYSTEM_APP
-
ApplicationInfo.FLAG_SYSTEM
ApplicationInfo.FLAG_UPDATED_SYSTEM_APP
ApplicationInfo.FLAG_SYSTEM
是系统的应用程序。您可以检查这样的标志:
are system apps. You can check for the flags like this:
List<ApplicationInfo> apps = getPackageManager().getInstalledApplications(0);
for(ApplicationInfo app : apps) {
if((app.flags & (ApplicationInfo.FLAG_UPDATED_SYSTEM_APP | ApplicationInfo.FLAG_SYSTEM)) > 0) {
// It is a system app
} else {
// It is installed by the user
}
}
这篇关于如何获得所有的应用程序(包括系统应用)的名单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文