Andrei Herford
Andrei Herford

Reputation: 18795

How to open default Mail App Inbox from within my Android app?

My Android 4+ app offers the user the possibility to setup a new user account for a web service. Once the user has sent the registration data, the new account is created and needs to be confirmed by clicking on a link which is sent to the user's e-mail address.

To make the registration as smooth as possible I would like to offer a "Go to your mail inbox" button once the data was submitted.

In iOS I can use the message:// URL scheme to do this. When my app calls such an URL iOS automatically switches to the Mail app.

How can this be done on Android?

Of course, I know about new Intent(Intent.ACTION_SEND)... to create and send a new mail but this is not what I am looking for. The user should not send an e-mail but check his inbox for new emails.

EDIT:

This is not a duplicate of the linked question since this is not about starting a specific app (e.g. "com.google.android.gm") but the systems default mail app.

Upvotes: 1

Views: 1946

Answers (2)

André Sousa
André Sousa

Reputation: 1730

You can use the following:

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

From the documentation:

Used with ACTION_MAIN to launch the email application. The activity should be able to send and receive email.

Upvotes: 4

navylover
navylover

Reputation: 13629

You could use Intent.ACTION_VIEW like below:

final Intent emailLauncher = new Intent(Intent.ACTION_VIEW);
emailLauncher.setType("message/rfc822");
try{
       startActivity(emailLauncher);
}catch(ActivityNotFoundException e){

}

Upvotes: 1

Related Questions