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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…