Intent Filter to capture all sharing Intents

2019-02-02 15:59发布

问题:

How can I set my activity to be able to respond to any type of Sharing Intent.

I have tried:-

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="*"/>
</intent-filter>

However this does not work, I have read http://developer.android.com/guide/topics/intents/intents-filters.html but it is not clear how to be that open?

Any help will be much appreciated.

回答1:

This is how it is done:-

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="application/*" />
    <data android:mimeType="audio/*" />
    <data android:mimeType="image/*" />
    <data android:mimeType="message/*" />
    <data android:mimeType="multipart/*" />
    <data android:mimeType="text/*" />
    <data android:mimeType="video/*" />
</intent-filter>


回答2:

        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:mimeType="application/*" />
            <data android:mimeType="audio/*" />
            <data android:mimeType="image/*" />
            <data android:mimeType="message/*" />
            <data android:mimeType="multipart/*" />
            <data android:mimeType="text/*" />
            <data android:mimeType="video/*" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND_MULTIPLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="application/*" />
            <data android:mimeType="audio/*" />
            <data android:mimeType="image/*" />
            <data android:mimeType="message/*" />
            <data android:mimeType="multipart/*" />
            <data android:mimeType="text/*" />
            <data android:mimeType="video/*" />
            <data android:mimeType="text/plain" />
        </intent-filter>


回答3:

<intent-filter>
   <action android:name="android.intent.action.SEND" />
   <category android:name="android.intent.category.DEFAULT" />
   <data android:mimeType="*/*" />
</intent-filter>


回答4:

Have you tried this?

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