Triggering email from a specific email account in android
Hi I am developing an android application in which a form has to be submitted over email. my code is as follows
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"mail id"});
i.putExtra(Intent.EXTRA_SUBJECT, "Subjec");
i.putExtra(Intent.EXTRA_TEXT ,"Hi"
startActivity(i);
When I click submit on the form it is triggering a spinner from which user has to select email to goto email. The problem it is showing hell lot of other unnecessary options such as bluetooth, colornote etc... I want only email or gmail to be shown or a better way it should directly goto email app开发者_开发知识库lication
Please kindly give me your valuable advice.
Thanking you Yours sincerely Chinnikrishna
Option #1: Use ACTION_SENDTO
as seen here and here.
Option #2: Use message/rfc822
instead of text/plain
(and format your message accordingly) as seen here.
Neither are guaranteed to only give you mail clients, though the first option is likely to only be mail clients.
Hi I found the answer to my question I need to add
i.setType("application/octet-stream");
Then it is giving me only gmail and email :-)
精彩评论