简体   繁体   English

Android为Intent.createChooser()指定应用程序列表

[英]Android specifying application list for Intent.createChooser()

I'm curious on the Intent.createChooser() method. 我对Intent.createChooser()方法感到好奇。 I've done some research but haven't been able to find the specific answer I was looking for. 我已经做过一些研究,但找不到我想要的具体答案。

I have a requirement that depending on which application the user picks (either email or text) I'm to format the text differently. 我有一个要求,根据用户选择的应用程序(电子邮件或文本),我将以不同的格式设置文本。 I'm OK with the chooser displaying other applications (I'd prefer to not remove options for users) but is there a way for my application to know which external application the user selected? 我可以选择器显示其他应用程序(我不希望不为用户删除选项),但是我的应用程序是否有办法知道用户选择了哪个外部应用程序? From there I could maybe overload the initial Intent and send the properly formatted data. 从那里,我可能会重载初始Intent并发送格式正确的数据。

Thank you in advance for any help. 预先感谢您的任何帮助。

I'm OK with the chooser displaying other applications (I'd prefer to not remove options for users) but is there a way for my application to know which external application the user selected? 我可以选择器显示其他应用程序(我不希望不为用户删除选项),但是我的应用程序是否有办法知道用户选择了哪个外部应用程序?

No, sorry. 不,对不起

For that, you would need to create your own chooser dialog, using PackageManager and queryIntentActivities() . 为此,您需要使用PackageManagerqueryIntentActivities()创建自己的选择器对话框。 Based on what the user chooses in that dialog, you can then set the appropriate extras on the Intent , along with the selected ComponentName , and use the resulting Intent with startActivity() . 根据用户在该对话框中选择的内容,然后可以在Intent上设置适当的附加功能,以及所选的ComponentName ,然后将结果IntentstartActivity()

(one of these days, I'll write one of these dialogs, as this question comes up a lot...) (这些天之一,我将编写其中一个对话框,因为这个问题经常出现……)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM