0

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 application

Please kindly give me your valuable advice.

Thanking you Yours sincerely Chinnikrishna

8A52
  • 793
  • 3
  • 12
  • 23

2 Answers2

3

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.

Community
  • 1
  • 1
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

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 :-)

8A52
  • 793
  • 3
  • 12
  • 23