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("test@gmail.com"))
    .setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail")
    .putExtra(Intent.EXTRA_EMAIL, new String[]{"test@gmail.com"})
    .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[] { "test@gmail.com" });

for single emails:

intent.setData(Uri.parse("test@gmail.com"));

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

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

Leave a Comment