如何获得在Android和安装的应用程序没有系统的应用程序? [英] How to get installed applications in Android and no system apps?
本文介绍了如何获得在Android和安装的应用程序没有系统的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想它出现在菜单屏幕的所有应用程序。不过,现在我只得到了用户安装的应用程序或所有应用程序(包括系统应用程序)。
我目前的code是:
最后PackageManager PM = getActivity()getPackageManager()。
名单< PackageInfo>应用程序= pm.getInstalledPackages(PackageManager.GET_META_DATA);
ArrayList的< PackageInfo> AUX =新的ArrayList< PackageInfo>();
的for(int i = 0; I< apps.size();我++){
如果(apps.get(ⅰ).versionName =空&安培;!及((apps.get(ⅰ).applicationInfo.flags&安培;!ApplicationInfo.FLAG_SYSTEM)= 1)){
aux.add(apps.get(ⅰ));
}
通过这个code,我可以让用户安装的应用程序,而且如果我评论的'如果'的指令,我将得到系统的应用程序。
所以,我想获得用户安装的应用程序和应用程序,如联系人,画廊等。
更新:
最后PackageManager PM = getActivity()getPackageManager()。
意向意图=新的意图(Intent.ACTION_MAIN,NULL);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
名单< ResolveInfo>应用程序= pm.queryIntentActivities(意向,PackageManager.GET_META_DATA);
解决方案
最后PackageManager PM = getActivity()getPackageManager()。
意向意图=新的意图(Intent.ACTION_MAIN,NULL);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
名单< ResolveInfo>应用程序= pm.queryIntentActivities(意向,PackageManager.GET_META_DATA);
I want to get all application which appears in the menu screen. But, now I only get the user installed apps or all the application (included the system application).
My current code is:
final PackageManager pm = getActivity().getPackageManager();
List<PackageInfo> apps = pm.getInstalledPackages(PackageManager.GET_META_DATA);
ArrayList<PackageInfo> aux = new ArrayList<PackageInfo>();
for (int i = 0; i < apps.size(); i++) {
if (apps.get(i).versionName != null && ((apps.get(i).applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 1)) {
aux.add(apps.get(i));
}
With this code, I can get the user installed apps, and if I comment the 'if' instruction, I will get the system apps.
So, I want to get the user installed apps and apps like contacts, gallery and so on.
UPDATE:
final PackageManager pm = getActivity().getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> apps = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
解决方案
final PackageManager pm = getActivity().getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> apps = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
这篇关于如何获得在Android和安装的应用程序没有系统的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文