0

I'm trying to have the user e-mail me when they click a button, and use this code to do so. While it works, it brings up a lot of other applications that cant handle e-mail, like Twitter and Facebook. What's missing?

String[] email = {"evan@example.com"};

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_EMAIL,email);
context.startActivity(sendIntent);
jfisk
  • 6,125
  • 20
  • 77
  • 113

2 Answers2

0
// start the activity
context.startActivity(sendIntent); 

// start the activity asking the user how to send the email
context.startActivity(Intent.createChooser(sendIntent, "Email:")); 

So you need to remove the last line.

see http://developer.android.com/reference/android/content/Intent.html

0
  final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
  emailIntent .setType("plain/text");
  emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"evan@example.com"});
  emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Subject");                 
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg);
startActivity(Intent.createChooser(emailIntent, "Send mail"));  
Umesh
  • 4,406
  • 2
  • 25
  • 37
  • the line that fixed it was changing emailIntent.setType("text/plain"); to emailIntent.setType("plain/text"); – jfisk Aug 22 '11 at 16:31