简体   繁体   English

Android获取所有已安装应用的列表

[英]Android get a list of all installed apps

I have obtained a list of installed app using this code: 我已使用以下代码获取已安装应用的列表:

public List<ResolveInfo>() {
    PackageManager pm=getPackageManager();
    Intent main=new Intent(Intent.ACTION_MAIN, null);

    main.addCategory(Intent.CATEGORY_LAUNCHER);

    List<ResolveInfo> launchables=pm.queryIntentActivities(main, 0);

}

There is only a problem: it list only apps that has a MAIN activity. 只有一个问题:它只列出具有MAIN活动的应用程序。 How can I get a List of all installed apps? 如何获取所有已安装应用的列表? Note that I used this code in a project that need that the List is of ResolveInfo, so please answer only code that returns a List of ResolveInfo. 请注意,我在需要List为ResolveInfo的项目中使用此代码,因此请仅回答返回ResolveInfo列表的代码。

Have you tried with: 你尝试过:

 List<ApplicationInfo> packages = pm
            .getInstalledApplications(PackageManager.GET_META_DATA);

(found here ) (在这里找到)

Your question doesn't quite make sense; 你的问题没有意义; you're making a bit of an unreasonable request. 你提出了一些不合理的要求。 You say you want a list of all installed apps, but you also want a List of ResolveInfo objects. 您说您想要所有已安装应用的列表,但您还需要一个ResolveInfo对象List The docs of ResolveInfo describe it as: ResolveInfo文档将ResolveInfo描述为:

Information that is returned from resolving an intent against an IntentFilter. 从解析针对IntentFilter的意图返回的信息。

Apps and IntentFilter s don't correlate one to one. Apps和IntentFilter不会一对一关联。 What would you want the ResolveInfo objects to contain? 你希望ResolveInfo对象包含什么? If there's more than one for a package, which one would you want? 如果一个包装不止一个,你想要哪一个?

PackageManager does include a method getInstalledApplications , but it returns a List of ApplicationInfo objects which is a more appropriate type for this sort of query. PackageManager确实包含一个方法getInstalledApplications ,但它返回一个ApplicationInfo对象的List ,这是一种更适合这种查询的类型。 Likewise there's a getInstalledPackages method as well that returns a List of PackageInfo objects. 同样,还有一个getInstalledPackages方法,它返回一个PackageInfo对象的List

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获取android中所有已安装应用的图标 - Get icons of all installed apps in android 如何在Android手机上安装所有应用程序 - How to get all apps installed on android phone 获取android中所有已安装应用的缓存目录 - Get Cache Directory for all installed apps in android Android-获取已安装应用程序签名的列表 - Android - get list of installed apps signatures 如何获取 Android 11 中已安装应用程序的列表 - How to get a list of installed apps in Android 11 Android:获取包括系统应用在内的所有已安装应用列表的问题 - Android: Issue in getting a list of all installed apps including system apps 获取android 11(API 30)中所有已安装的应用程序,如何获取android 11中安装的所有其他应用程序? - Get all installed apps in android 11 (API 30) , how to get all other apps installed in android 11? 如何在 Android 中获取并列出所有已安装/可用的导航应用程序及其图标? - How to get and list all the installed/available navigations apps along with their icons in Android? 如何在Android的字符串数组列表中获取所有已安装的应用程序名称,包括系统应用程序 - How to get all the installed application's name including system apps in a string array list in android Android:列出所有已安装的应用程序并获取每个应用程序的总运行时间 - Android: List all installed apps and get total running time of each app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM