Intent URI to launch Gmail App

This works to intent just the gmail app.

final Intent intent = new Intent(Intent.ACTION_VIEW)
    .setType("plain/text")
    .setData(Uri.parse("[email protected]"))
    .setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail")
    .putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"})
    .putExtra(Intent.EXTRA_SUBJECT, "test")
    .putExtra(Intent.EXTRA_TEXT, "hello. this is a message sent from my demo app :-)");
startActivity(intent);

use for plenty of emails:

intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]" });

for single emails:

intent.setData(Uri.parse("[email protected]"));

You may add extra putExtra(Intent.EXTRA..) and change the setType for your purpose. :P

Update (1/22/14): It is important to note that if you are going to use this code, you check to make sure that the user has the package "com.google.android.gm" installed on their device. In any language, make sure to check for null on specific Strings and initializations.

Please see Launch an application from another application on Android

enter image description here


I'm using this in my apps:

Intent mailClient = new Intent(Intent.ACTION_VIEW);
mailClient.setClassName("com.google.android.gm", "com.google.android.gm.ConversationListActivity");
startActivity(mailClient);

Using package name is not recommended as its an undocumented method. In case if the package name changes some day the code will fail.

Try this code instead

 Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
 "mailto", "[email protected]", null));
 emailIntent.putExtra(Intent.EXTRA_SUBJECT, "This is my subject text");
 context.startActivity(Intent.createChooser(emailIntent, null));

Ref: http://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO\