如何获得安装Android应用程序的列表,并选择一个运行 [英] How to get a list of installed android applications and pick one to run

查看:80
本文介绍了如何获得安装Android应用程序的列表,并选择一个运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我问过类似的问题,这在本周早些时候,但我还是不理解如何让所有安装的应用程序列表,然后选择一个运行。

I asked a similar question to this earlier this week but I'm still not understanding how to get a list of all installed applications and then pick one to run.

我已经试过:

Intent intent = new Intent(ACTION_MAIN);
intent.addCategory(CATEGORY_LAUNCHER);

和这只能说明应用程序在preinstalled或者可以运行ACTION_MAIN意图类型。

and this only shows application that are preinstalled or can run the ACTION_MAIN Intent type.

我也知道我可以使用PackageManager得到所有已安装的应用程序,但我怎么用它来运行特定的应用程序?

I also know I can use PackageManager to get all the installed applications, but how do I use this to run a specific application?

感谢

推荐答案

以下是code以获得安装在Android活动/应用程序的列表:

Following is the code to get the list of activities/applications installed on Android :

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);

您将获得在ResolveInfo所有必要的数据来启动应用程序。您可以检查ResolveInfo的javadoc 这里

You will get all the necessary data in the ResolveInfo to start a application. You can check ResolveInfo javadoc here.

心连心!

这篇关于如何获得安装Android应用程序的列表,并选择一个运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆