Is this even possible without calling a specific package? I have found countless examples of sending email via intent, but I can find nothing about simply opening the default email client on the device via button press (preferably with a chooser dialog in case the user has multiple clients).
Asked
Active
Viewed 5,555 times
5
-
I'm curious why you want to do this. – Tyler Aug 15 '10 at 23:05
-
The client wants their app to have an "email" button which simply launches the default mail client to check company mail. – wirbly Aug 15 '10 at 23:16
4 Answers
19
There is no default/easy way to do this. This code worked for me. It opens a picker with all email apps registered to device and straight to Inbox:
Intent emailIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:"));
PackageManager pm = getPackageManager();
List<ResolveInfo> resInfo = pm.queryIntentActivities(emailIntent, 0);
if (resInfo.size() > 0) {
ResolveInfo ri = resInfo.get(0);
// First create an intent with only the package name of the first registered email app
// and build a picked based on it
Intent intentChooser = pm.getLaunchIntentForPackage(ri.activityInfo.packageName);
Intent openInChooser =
Intent.createChooser(intentChooser,
getString(R.string.user_reg_email_client_chooser_title));
// Then create a list of LabeledIntent for the rest of the registered email apps
List<LabeledIntent> intentList = new ArrayList<LabeledIntent>();
for (int i = 1; i < resInfo.size(); i++) {
// Extract the label and repackage it in a LabeledIntent
ri = resInfo.get(i);
String packageName = ri.activityInfo.packageName;
Intent intent = pm.getLaunchIntentForPackage(packageName);
intentList.add(new LabeledIntent(intent, packageName, ri.loadLabel(pm), ri.icon));
}
LabeledIntent[] extraIntents = intentList.toArray(new LabeledIntent[intentList.size()]);
// Add the rest of the email apps to the picker selection
openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents);
startActivity(openInChooser);
}

Larisa Hogas
- 271
- 3
- 3
-
1Initially this looked like very scary code, but it worked nonetheless! I added an else statement for phones which have no mail client installed. – user1354603 Feb 09 '15 at 10:41
-
1This code was the only one solution which I found to help me open email inbox (without to write new email message), and at the same time it gives you chooser dialog, which is awesome , Thanks Larisa – Stoycho Andreev Sep 17 '16 at 18:21
-
The only bit of code out there that works. You should wrap it into a helper and throw it on GitHub Gists. THNX! – Jan 30 '17 at 16:29
-
The best answer by far. Creates a chooser of all emails available, and when clicked, just launches the app. – Jeff Padgett Nov 15 '19 at 15:24
-
For newer version of android and kotlin check this answer https://stackoverflow.com/a/69043615/3289338 – Timo Sep 08 '21 at 12:18
7
There is no standard Intent
action to open the "inbox view" of "the default email client on the device".

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
1Is there any standard intent action I can use to open the default email client? (Even if it's not the inbox view - just launch the app in the same way touching the icon on the home screen would launch it) – wirbly Aug 15 '10 at 23:21
-
Ok, thanks for the info. Looks like I'm calling a specific package, then. – wirbly Aug 16 '10 at 13:12
4
This one works nowadays
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.APP_EMAIL");
startActivity(Intent.createChooser(intent, ""));

Lassi Kinnunen
- 448
- 4
- 10
-
2This will only open Gmail, not open a chooser for the email app of your choice. – Jeff Padgett Nov 14 '19 at 22:54
-
Okay, which android version? I'm fairly sure that it gave the chooser last year when I tried it, provided that you have more than one app that claims to do that APP_EMAIL. – Lassi Kinnunen Nov 19 '19 at 06:25
-
-
I just tried this code on nexus 5x api 29 emulator after installing the samsung email client and it gives a choice between the two email clients. After uninstalling the samsung email client from the emulator it will just open gmail directly. What other email client did you have installed in the emulator? maybe it doesn't implement the listener for the intent like it should. – Lassi Kinnunen Nov 26 '19 at 05:04
-
1I had Yahoo Mail installed as an app on the emulator. On my own Samsung 7 I also had Outlook, which did not open with this version. Have you tried on earlier api levels ? I recommend you trying this again as it doesn't appear to be working the way you intend. – Jeff Padgett Dec 07 '19 at 05:32
-
Thanks, this code works for me. Intent intent= new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_APP_EMAIL); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, "")); – Anh Duy Nov 29 '22 at 08:53
-
Maybe I should have added the caveat that if for an action you have selected the "Always use this app" it will not ask which app to use until you install another app that has a handler for the action. – Lassi Kinnunen Dec 01 '22 at 06:06
1
you can try this from your activity object:
it will not necessarily take you to the Inbox directly but it will open the email application:
Intent intent = getPackageManager().getLaunchIntentForPackage("com.android.email");
startActivity(intent);

Marvin Pinto
- 30,138
- 7
- 37
- 54

samer alameer
- 27
- 3
-
This one just works, if the Android Email client is the default email program (rarely the case). If it's not, startActivity throws an exception. – KPK Feb 07 '12 at 02:38
-
even if its the default app it wouldn't work.i remember that some htc phone had the email package named differently, something like "com.htc.android.email". so this wouldn't work – samer alameer Feb 07 '12 at 18:33