lundi 18 mai 2015

Sending email using standard gmail app without chooser

I'm trying send email from my app using standard gmail app. But I get chooser all the time. How can I open standard gmail app immediately without chooser? Thank you! Here is my code.

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.setClassName("com.google.android.gm", "com.google.android.gm.ConversationListActivity");
intent.putExtra(Intent.EXTRA_EMAIL  , new String[]{"mymail@gmail.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT   , "Text");
try {
    startActivity(intent);
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(getApplicationContext(), "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}

Aucun commentaire:

Enregistrer un commentaire