How to open the default mail inbox from android code?

Sander Swart picture Sander Swart · Nov 11, 2011 · Viewed 19.7k times · Source

I'm trying to link a button to the mail app. Not to send mail, but just to open the inbox.

Should I do this with Intent intent = new Intent(...)?

If so, what should be between the ( )?

Answer

Ben Yee picture Ben Yee · Jul 23, 2015

If the goal is to open the default email app to view the inbox, then key is to add an intent category and use the ACTION_MAIN intent like so:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_EMAIL);
getActivity().startActivity(intent);

https://developer.android.com/reference/android/content/Intent.html#CATEGORY_APP_EMAIL