Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android show all email applications in a chooser without composing a new email

Tags:

android

In my application I wish to send a server-side authentication email. I'd like to open a chooser that shows every email application available on the device.

I can do this with the following lines code:

 Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
 emailIntent.setData(Uri.parse("mailto:"));

Problem 1: This will always compose an empty message, all I want to do is display every email application so that the user will be directed to their desired inbox.

Upon further research I found that I can open the email application (without composing a new message) by adding a category type:

Intent emailIntent = new Intent(Intent.ACTION_MAIN);
emailIntent.addCategory(Intent.CATEGORY_APP_EMAIL);

Problem 2: This solution will only show the default email application only (testing on a Samsung device means that only the 'Email' app is shown not third party apps such as Gmail, Outlook etc). This is not ideal as I'd like to offer the user the ability to open their email client of choice.

Most resources online show how to send an email via your own application however I have not found any way to show the user every email app but NOT compose a new email.

Any help would be greatly appreciated, thanks!

like image 769
stepwise_refinement Avatar asked May 16 '16 14:05

stepwise_refinement


People also ask

Is there a better email app than Gmail?

ProtonMail also offers calendar and storage drive products with all email accounts, making it one of the best alternatives to Gmail. Features: Android and iOS apps, along with a web-based inbox.

What is the best email app for multiple accounts?

Gmail (Android, iOS: Free) The Gmail app supports multiple accounts and notifications, while also offering particularly handy tools for organizing your emails.


1 Answers

Your CATEGORY_APP_EMAIL is documented to specifically be not used the way that you are using it. It is for makeMainSelectorActivity(), which should in theory give you what you want. Try:

Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,
    Intent.CATEGORY_APP_EMAIL);

and see if that gives you what you want.

I'd like to open a chooser that shows every email application available on the device.

Bear in mind that the user may be using none of these. They might use Web mail in a browser. They might not access email on their mobile device. They might not use email. They might think that email is something for old people. And so on.

like image 125
CommonsWare Avatar answered Sep 20 '22 09:09

CommonsWare