启动任何已安装的应用程序 [英] Starting ANY of the installed apps

查看:72
本文介绍了启动任何已安装的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,用户可以在其中滚动浏览所有已安装应用程序的列表,然后他可以选择任何应用程序并启动它.

i have and app in which the user can scroll through a list of all installed apps and he can pick any app and starts it.

对于大多数应用程序,此功能可以很好地配合使用:

For most Apps this works fine with:

startActivity(getPackageManager().getLaunchIntentForPackage(packageName_selectedapp));

其中packageName_selectedapp是从列表中选择的应用程序的字符串.

where packageName_selectedapp is the string of the selected app from the list.

对于某些应用程序,功能getLaunchIntentForPackage(packageName_selectedapp)返回空",例如,如果它是拨号程序或联系人活动.

BUT for some apps the function getLaunchIntentForPackage(packageName_selectedapp) returns "null", for instance if it is the dialer or contacts activity.

如何获取拨号器和联系人的launchIntent?

How can i get the launchIntent for dialer and contacts?

提前谢谢!

推荐答案

如何获取拨号器和联系人的launchIntent?

How can i get the launchIntent for dialer and contacts?

这些不是应用程序.这些是另一个应用程序的其他可启动活动.

Those are not apps. Those are other launchable activities of another app.

因此,您需要确定所写的内容.

Hence, you need to decide what it is that you are writing.

您说您拥有所有已安装应用程序的列表,他可以选择任何应用程序并启动它".在这种情况下,您特别不希望使用拨号器和联系人",因为它们不是应用程序.

You said that you have "a list of all installed apps and he can pick any app and starts it". In that case, you specifically do not want "dialer and contacts", as those are not apps.

相反,如果您想显示用户可以从中进行选择的所有可启动活动的列表,则您将不会使用 getLaunchIntentForPackage().相反,您可以使用 queryIntentActivities()查找那些可启动的活动.我有一个演示应用程序的示例应用程序,其形式为一个发射器.

If, instead, you want to show a list of all launchable activities, from which the user can pick, you would not be using getLaunchIntentForPackage(). Instead, you would use queryIntentActivities() to find those launchable activities. I have a sample app that demonstrates this, in the form of a launcher.

这篇关于启动任何已安装的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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