Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent URI to launch Gmail App

Is there any URI which can point to the GMAIL App in android and help me launch it?

like image 755
Sana Avatar asked Aug 12 '10 16:08

Sana


People also ask

How do I open Gmail with intent?

Use this: Intent intent = getPackageManager(). getLaunchIntentForPackage("com.google.android.gm"); startActivity(intent);

How do I open Gmail app on Android?

From the Home screen, tap the Apps icon (in the QuickTap bar) > the Apps tab (if necessary) > Google folder > Gmail or tap Google folder > Gmail on the Home screen.

What is com google/android GM?

Google Mobile Services (GMS) is a collection of Google applications and APIs that help support functionality across devices. These apps work together seamlessly to ensure your device provides a great user experience right out of the box.


2 Answers

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

like image 64
Jared Burrows Avatar answered Oct 14 '22 05:10

Jared Burrows


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);
like image 42
katzoft Avatar answered Oct 14 '22 04:10

katzoft