12

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.

3
  • 2
    The data filter can only be wildcard:ed on the subtype, ("text/plain" has the subtype "plain" for instance) - so you'd need to add "application/*", "audio/*", "image/*" etc. etc. to your filters.
    – Jens
    Mar 2, 2012 at 7:59
  • So @Jens do you meant that I have to add each and every data filter individually? If so is there somewhere I can get a list of them from?
    – baynezy
    Mar 2, 2012 at 15:19
  • 4
    RFC1341 lists all the "well-defined" types. Then, there's of course a lot of people who just likes to take huge steaming shits on top of standards and make up their own types without using the x-token format.
    – Jens
    Mar 2, 2012 at 15:37

5 Answers 5

32

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>
6
        <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>
2
  • 1
    You should add some explanation for the code you've provided. Sep 22, 2012 at 6:51
  • 1
    The comment about */* not working must be dated, because the source code for Send to SD card contains the exact intent-filter above in it's AndroidManifest.xml. And the program works like intended (on Android 6.0.1).
    – hlovdal
    Nov 5, 2016 at 19:25
0

This should work fine:

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

Have you tried this?

    <intent-filter>
        <category android:name="android.intent.category.DEFAULT" />
        <action android:name="android.intent.action.SEND" />
    </intent-filter>
1
  • Yeah, I have tried that but my application is never listed when I share something.
    – baynezy
    Mar 2, 2012 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.