every time i create an action for sending an email from my app, it prompts to many options including a QR client...
Is there a way to force sending via email clients onl
I think you should change the setType
to
i.setType("message/rfc822") ;
Even though it's too late for @thepoosh, but it may be helpful for future questioners. After a lot of searching and testing, I finally found a good solution. Thanks to the Open source developer, cketti for sharing his/her concise solution.
String mailto = "mailto:bob@example.org" +
"?cc=" + "alice@example.com" +
"&subject=" + Uri.encode(subject) +
"&body=" + Uri.encode(bodyText);
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse(mailto));
try {
startActivity(emailIntent);
} catch (ActivityNotFoundException e) {
//TODO: Handle case where no email app is available
}
This is the link to his/her gist.
As long as you are using ACTION_SEND
with type text/plain
, it will show all the valid options. However, if you want, you may design your your own dialog window which shows only Gmail or other mail client by doing filtering programatically.
BTW, why do you even need this window when you just want to use Gmail?
String rec[] = { owner.email };
i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822") ;
i.putExtra(android.content.Intent.EXTRA_EMAIL, rec);
i.putExtra(android.content.Intent.EXTRA_SUBJECT, "RE: " + desc);
i.putExtra(android.content.Intent.EXTRA_TEXT,
"\n\n\nSent from Mojo for Android");
startActivity(i);
try this;:::
Try to setType message/rfc822
instead of text/plain
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { "abc@xyz.com" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Subject of the Mail");
emailIntent.putExtra( android.content.Intent.EXTRA_TEXT,
"This is my sample Mail");
emailIntent.setType("vnd.android.cursor.dir/email");
startActivity(Intent.createChooser(emailIntent, "Email:"));
else use this it will shows only the mail clients,
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { "abc@xyz.com" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Subject of the Mail");
emailIntent.putExtra( android.content.Intent.EXTRA_TEXT,
"This is my sample Mail");
//emailIntent.setType("vnd.android.cursor.dir/email");
startActivity(Intent.createChooser(emailIntent, "Email:"));