Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android intent-filter to listen for sent email addresses?

I would like my app to be able to respond when an email address is "sent" in an intent. for example, when a user clicks on an email address in the contacts app, the gmail and email apps show up. i'd like to get into that list.

my first attempt was to match on scheme="mailto",

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

which did not work. next attempt was to match pathPattern=".@.".

            <data android:pathPattern=".*@.*" />

this didn't work, and as the JD's say, that's only meaningful if the host, scheme is specified.

any ideas?

like image 752
Jeffrey Blattman Avatar asked Jul 22 '11 20:07

Jeffrey Blattman


People also ask

What does the intent filter do in android?

An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle. It opens the component to receiving intents of the advertised type, while filtering out those that are not meaningful for the component.

What is intent filters explain intent filters with example?

Implicit intent uses the intent filter to serve the user request. The intent filter specifies the types of intents that an activity, service, or broadcast receiver can respond. Intent filters are declared in the Android manifest file. Intent filter must contain <action>

What is startActivity?

Starting activities or services. To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent.

What is the difference between intent and intent filters?

An intent is an object that can hold the os or other app activity and its data in uri form.It is started using startActivity(intent-obj).. \n whereas IntentFilter can fetch activity information on os or other app activities.


1 Answers

The Email app uses:

<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>
<intent-filter android:label="@string/app_name">
    <action android:name="android.intent.action.SEND"/>
    <data android:mimeType="*/*"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter android:label="@string/app_name">
    <action android:name="android.intent.action.SEND_MULTIPLE"/>
    <data android:mimeType="*/*"/>
    <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
like image 136
CommonsWare Avatar answered Nov 14 '22 05:11

CommonsWare