本文介绍了如何获取用户已在Android设备上安装的应用程序的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用以下代码:
I am using the following piece of code at the moment:
List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);
,但它返回由设备制造商和我安装的应用程序.如何限制它,以便仅返回我安装的应用程序?
but it returns Apps that have been installed by the both device manufacturer and me. How to limit it so that only the apps that I installed are returned?
推荐答案
// Flags: See below
int flags = PackageManager.GET_META_DATA |
PackageManager.GET_SHARED_LIBRARY_FILES |
PackageManager.GET_UNINSTALLED_PACKAGES;
PackageManager pm = getPackageManager();
List<ApplicationInfo> applications = pm.getInstalledApplications(flags);
for (ApplicationInfo appInfo : applications) {
if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
// System application
} else {
// Installed by user
}
}
标志:
- GET_META_DATA
- GET_SHARED_LIBRARY_FILES
- GET_UNINSTALLED_PACKAGES
这篇关于如何获取用户已在Android设备上安装的应用程序的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!