700 Software
700 Software

Reputation: 87763

Make my activity one of the mail apps shown in the intent chooser

When clicking an email address from a browser or contacts app...

Is there any way for my app to show a mail client in the intent list?

Upvotes: 0

Views: 2257

Answers (2)

Jess
Jess

Reputation: 42928

As you can see from the Mail application's source, having your application catch the intent is as simple as adding the intent-filter to your AndroidManifest.xml inside your mail composition activity definition.

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <action android:name="android.intent.action.SENDTO" />
    <data android:scheme="mailto" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

You can see that the <data> tag specifies to handle mailto: links. The BROWSABLE category means it can be launched from the browser.

K-9 Mail is similar, except using the SENDTO action only with the DEFAULT category, and the VIEW action only with the BROWSABLE category.

Upvotes: 4

Chris Thompson
Chris Thompson

Reputation: 35598

You need to use an Intent Filter. Check out http://developer.android.com/guide/topics/intents/intents-filters.html for more information. You usually declare these in your manifest file. The intent I believe you're looking for is Intent.ACTION_SEND.

Upvotes: 1

Related Questions