如何判断 Intent.createChooser 选择了哪个应用程序? [英] How to tell which app was selected by Intent.createChooser?

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

问题描述

代码:

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

我没有看到任何方法可以判断选择了哪个 Intent(HOME 类别启动器).没有 Intent.addOnActionSetListener,也没有 chooser.addOnIntentChosenListener 等.

I don't see any way to tell which Intent (HOME category launcher) was selected. There is no Intent.addOnActionSetListener, and no chooser.addOnIntentChosenListener etc.

那么我怎么知道哪个被选中了?我是否必须为此编写自己的选择器?

So how can I tell which was selected? Do I have to write my own chooser for this?

推荐答案

在 Android 5.1+ 上,您可以使用 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.

在 Android 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天全站免登陆