如何启动从另一个应用程序的应用程序? [英] How to launch applications from another application?

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

问题描述

我要启动从我的application.Here我得到的所有安装的应用程序

I want to launch all installed applications from my application.Here i get all installed applications

List<ApplicationInfo> applicationInfoList = packageManager.getInstalledApplications(PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA);
if(applicationInfoList != null && !applicationInfoList.isEmpty()){
    Collections.sort(applicationInfoList, new ApplicationInfo.DisplayNameComparator(
            packageManager));
    for (ApplicationInfo applicationInfo : applicationInfoList) {
        Intent intent = packageManager.getLaunchIntentForPackage(applicationInfo.packageName);
        if(intent != null){
            ComponentName componentName = intent.getComponent();
            //add componenet to a list
        }

    }
}

但我不能像发动联系人和Phone.The类名某些应用程序是'ResolverActivity这些apps.How ca的,我从我的应用程序启动这些应用程序?

But i can't launch some applications like Contacts and Phone.The class name is 'ResolverActivity' for these apps.How ca i launch these apps from my applications?

由于提前

推荐答案

这是因为,联系人和电话都相同的应用程序,因为是地图和纬度。他们碰巧有多个可启动的活动。

This is because Contacts and Phone are the same application, as are Maps and Latitude. They happen to have multiple launchable activities.

所以,你有两个选择:


  1. 坚持要发动所有已安装的应用程序的说法,在这种情况下,现有的code是正确的(用户将选择是否显示联系人或电话),或

  1. Stick with your statement that you want to "launch all installed applications", in which case your existing code is correct (the user will choose whether to show Contacts or Phone), or

做一个主屏幕发射做什么,这就是发动全体可启动的活动,在这种情况下,你会有关它的错误

Do what a home screen launcher does, which is "launch all launchable activities", in which case you are going about it wrong

对于后者,使用 queryIntentActivities() / LAUNCHER 意图,并用结果来建立您的清单。 下面是一个说明这是一个示例应用程序

For the latter, use queryIntentActivities() for a MAIN/LAUNCHER Intent, and use the results to build your list. Here is a sample application that demonstrates this.

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

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