17

I need to provide feature for users where users can share some data by sending email. I used below code.

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "testing email send.");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<b>this is html text in email body.</b>"));
startActivity(Intent.createChooser(emailIntent, "Email to Friend"));

This shows mail app, gmail and bluetooth for user to choose. I dont want user to show bluetooth in this list. What i need to do ? I have facebook app, which does same thing, but doesn't show bluetooth in the list. I need to do the same.

Umakant Patil
  • 2,227
  • 6
  • 32
  • 58

3 Answers3

15

You can use the ACTION_SENTTO instead of ACTION_SEND to get the list of e-mail clients. I tried this on HTC Wildfire which had default e-mail client, GMail app and k9-3.508-release installed. When I ran your code with ACTION_SENDTO, I got list of above mentions 3 e-mail clients and not bluetooth no matter if bluetooth was enabled or disabled. I tried it both when the bluetooth was enabled and when bluetooth was disabled. It worked well for me.

Intent emailIntent = new Intent(android.content.Intent.ACTION_SENDTO);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "testing email send.");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<b>this is html text in email body.</b>"));
startActivity(Intent.createChooser(emailIntent, "Email to Friend"));
madlymad
  • 6,367
  • 6
  • 37
  • 68
Ashish Pathak
  • 686
  • 4
  • 16
  • 9
    It doesn't work for me. ACTION_SEND shows GMail, but ACTION_SENDTO says "No applications can perform this action". – Patrick Sep 10 '11 at 20:28
  • Tested on a Samsung Galaxy Tab with no email recipient and HTML MIME type and it does not work: it says "No application can perform this action", i.e. also Gmail gets filtered out. – Mauro Vanetti Nov 22 '11 at 12:13
  • Does not work for me too.. Tested on Nexus S (Android 4.1.2), HTC (Android 2.3.3). – Karthik Andhamil Dec 21 '12 at 17:28
14

Try using this type instead:

emailIntent.setType("message/rfc822");
Ayush
  • 41,754
  • 51
  • 164
  • 239
per_jansson
  • 2,103
  • 4
  • 29
  • 46
  • Thanks :) It opens gmail app instead of showing list of email apps like Default Mail and Gmail. – Umakant Patil Jan 17 '11 at 11:28
  • You are welcome. Don't forget to mark the answer accepted, else the question will remain unanswered. – per_jansson Jan 17 '11 at 11:50
  • I know :) But the expected answer is still no there then how will i mark is as accepted answer ? You solutions just opens gmail app. I want the list as it is. Just don't want bluetooth into it. – Umakant Patil Jan 17 '11 at 12:38
1

Try adding the EXTRA_EMAIL to your intent, maybe bluetooth can be connected to ACTION_SEND but not to the same action if an email is to be send.

See here:
http://developer.android.com/reference/android/content/Intent.html#ACTION_SEND and here
http://developer.android.com/reference/android/content/Intent.html#EXTRA_EMAIL

Just a rough guess ...

Select0r
  • 12,234
  • 11
  • 45
  • 68