如何知道哪些应用程序是由Intent.createChooser选择? [英] How to tell which app was selected by Intent.createChooser?

查看:137
本文介绍了如何知道哪些应用程序是由Intent.createChooser选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

code:

        Intent launchIntent = new Intent(Intent.ACTION_MAIN);
        launchIntent.addCategory(Intent.CATEGORY_HOME);
        Intent chooser  = Intent.createChooser(launchIntent, "Complete Action using..");
        activity.startActivity(chooser);

我看不出有什么方法来判断哪些意图(HOME类启动器)被选中。没有Inent.addOnActionSetListener,也没有chooser.addOnIntentChosenListener等,所以我怎么能知道哪些选择?难道还是我写我自己的选择器来呢?

I don't see any way to tell which Intent (HOME category launcher) was selected. There is no Inent.addOnActionSetListener, and no chooser.addOnIntentChosenListener etc. So how can I tell which was selected? Do Or do I have to write my own chooser for this?

推荐答案

在Android 5.1+,你可以使用<一个href="http://developer.android.com/reference/android/content/Intent.html#createChooser%28android.content.Intent,%20java.lang.CharSequence,%20android.content.IntentSender%29"相对=nofollow>的三参数版 createChooser()方法,其中最后一个参数是 IntentSender ,你可以用它来找出被选中。

On Android 5.1+, you can use the three-parameter edition of the createChooser() method, where the last parameter is an IntentSender that you can use to find out what was chosen.

在此之前的Andr​​oid 5.1,没有什么在Android中,让你知道什么样的用户选择。

Prior to Android 5.1, there is nothing in Android to let you know what the user chose.

这篇关于如何知道哪些应用程序是由Intent.createChooser选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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