I have a problem with setting type "message/rfc822" for intent to send e-mail with file attachment on Android emulator
I have made an application that uses URI example as you desired:
if(v.getId()==R.id.button3)
{
intent=new Intent(Intent.ACTION_SEND);
intent.setData(Uri.parse("mailto"));
String[]to={"akshkatheria@gmail.com","megakatheria@gmail.com"};
intent.putExtra(Intent.EXTRA_EMAIL, to);
intent.putExtra(Intent.EXTRA_SUBJECT, "hello");
intent.putExtra(Intent.EXTRA_TEXT, "hi");
intent.setType("message/rfc822");
chooser=intent.createChooser(intent, "send mail");
startActivity(chooser);
}
First, "to avoid a lot of applications in select list for user's choice", use ACTION_SENDTO
and a mailto:
Uri
.
Second, what you are experiencing is not "a problem of Android emulator" nor "old APIs". You need 1+ applications that are capable of handling the ACTION_SEND
Intent
and a MIME type of message/rfc822
. There is no guarantee that any given device will support that combination, let alone any given emulator. Your code needs to handle that, just as if you use ACTION_GOBBLEDYGOOK
or a MIME type of thisis/sonotreal
or whatever.
This is the solution. Use the below code, works perfectly...Got the solution after research.... :)
Intent testIntent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + "blah blah subject" + "&body=" +
"blah blah body" + "&to=" + "sendme@me.com");
testIntent.setData(data);
startActivity(testIntent);