问题描述
我的应用程序集成了电子邮件,用户可以在其中直接从应用程序提交错误报告、反馈等.我使用 application/octet-stream 作为 Intent 的 SetType.当您提交电子邮件时,您会看到内容选择器,它会显示来自 Evernote、Facebook、电子邮件等的各种项目.
My app integrates e-mail where the user can submit a bug report, feedback, etc. from the app directly. I'm using the application/octet-stream as the SetType for the Intent. When you go to submit the e-mail you get the content chooser and it shows various items from Evernote, Facebook, E-mail, etc.
我怎样才能让这个选择器只显示电子邮件,以免将用户与所有这些适合内容选择器类型的其他项目混淆?
How can I get this chooser to only show E-mail so as not to confuse the user with all these other items that fit the content chooser type?
谢谢.
推荐答案
我假设您正在使用 ACTION_SEND
Intent
操作,因为您实际上并没有打扰说明您正在使用什么,但您同意@Aleadam 的评论.
I am presuming that you are using the ACTION_SEND
Intent
action, since you did not bother to actually state what you're using, but you agreed with @Aleadam's comment.
我使用 application/octet-stream 作为 Intent 的 SetType.
这句话中没有任何内容将事情限制在电子邮件上.
Nothing in that sentence limits things to email.
ACTION_SEND
是一个通用的 Intent
操作,任何需要的应用程序都可以支持它.您所做的只是指明您要共享的数据以及该数据的 MIME 类型——从那里开始,用户可以从可用活动中进行选择.
ACTION_SEND
is a generic Intent
action that can be supported by any application that wants to. All you do is indicate what data you are sharing and the MIME type of that data -- from there, it is up to the user to choose from available activities.
正如@Jasoon 所指出的,您可以尝试将 message/rfc822
作为 MIME 类型.然而,这并不表示只提供电子邮件客户端"——它表示提供任何支持 message/rfc822
数据的东西".这很容易包括一些不是电子邮件客户端的应用程序.
As @Jasoon indicates, you can try message/rfc822
as the MIME type. However, that is not indicating "only offer email clients" -- it indicates "offer anything that supports message/rfc822
data". That could readily include some application that are not email clients.
如果您特别想通过电子邮件发送某些内容,请将 JavaMail 集成到您的应用程序中,或者在您的 Web 服务器上编写电子邮件转发脚本并调用它,或者其他什么.如果您使用 ACTION_SEND
,您就是在暗示用户想要什么才是最重要的,并且您希望用户能够通过用户选择的任何方式发送某某数据.
If you specifically want to send something by email, integrate JavaMail into your app, or write an email forwarding script on your Web server and invoke it, or something. If you use ACTION_SEND
, you are implicitly stating that it is what the user wants that matters, and you want the user to be able to send such-and-so data by whatever means the user chooses.
这篇关于Android 意图选择器仅显示电子邮件选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!