views:

340

answers:

3

I tried this code which I found here:

Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "[email protected]", null)); startActivity(intent);

But I get a message on the screen which reads "Unsupported Action". Any ideas of how to get this working?

Thanks!

A: 

Did you try

Intent intent = new Intent(
    Intent.ACTION_SENDTO,
    Uri.parse("mailto:[email protected]")
);
startActivity(intent);
jitter
Gave it a shot, still get the message:Unsupported ActionThis action is not currently supported.In a Toast-like bubble. Do I need to set up something in the manifest to let my app use this?
scuba
+3  A: 

Try this snippet:

/* Create the Intent */
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

/* Fill it with Data */
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");

/* Send it off to the Activity-Chooser */
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));

Key pieces: using EXTRA_EMAIL for your addresses and using createChooser() in case the user has more than one email client configured.

CommonsWare
Thanks, that worked :) I did try something like that initially but it just pulled up some messaging screen and not the email app. I think that was because, at the time, I didn't have an email account set up in the emulator?
scuba
What did you use the final keyword? Does that result in some sort of optimization I'm unaware of?
Scott
I didn't write the snippet. Personally, I probably would not have used the final keyword there.
CommonsWare
A: 

met the same question. any suggestion?

Damon
and i can successfully access the mail app on HTC Legend.
Damon