I implemented sending emails from my application.
I used this quesion on SO as a guide to achieve this, note that in the answers someone said to use setType("message/rfc822");
because it filters out all other email client that listen to the ACTION_SEND
intent.
My problem is that my galaxy tab 10.1 still has two application that listen to the intent, so a popup still opens asking me what email client I want to use. (The gMail app or the default eMail app). I can't uninstall one so the list won't popup, but I don't want to either.
Is there a way to force android to just use the first one in the list instantly? So the user can skip the popup dialog?
Here is my current code:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.notes_from_pf));
i.putExtra(Intent.EXTRA_TEXT , context.getString(R.string.mail_message));
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(context, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}