Android Intent Chooser to only show E-mail option

2019-01-13 16:32发布

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?

Thank you.

8条回答
姐就是有狂的资本
2楼-- · 2019-01-13 16:53

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.

I'm using the application/octet-stream as the SetType for the Intent.

Nothing in that sentence limits things to email.

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.

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.

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.

查看更多
狗以群分
3楼-- · 2019-01-13 17:01

There is a way more generic to do that, working with any MIME type.

See this post: How to customize share intent in Android?

查看更多
登录 后发表回答