Oleksandr Ivanov
Oleksandr Ivanov

Reputation: 21

How to check the default mail client

How can I determine what is a default mail client on Adnroid? It could be for example standard Mail app or GMail appliction, how to know which one is configured as default?

Upvotes: 2

Views: 362

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007594

There is no concept of a "default mail client on Android".

There is a concept of a default app for a specific Intent structure. Hence, an Intent to send an email (e.g., ACTION_SENDTO with a mailto: Uri) may be tied to a default app. To find out what that default is, create the desired Intent and use resolveActivity() on PackageManager. This will come back with:

  • The default app, if there is one
  • A resolver activity (e.g., the system chooser), if there is no default and there is more than one choice
  • The only email app, if there is only one choice
  • null, if there are no matching activities

Or, use PackageManager and getPreferredActivities() and sift through those for things that you think are mail clients.

Upvotes: 2

Related Questions