MGetto
MGetto

Reputation: 3

Android Intent Filter to receive image files is only working in some apps

I'm experimenting with android development. As an exercise I want to create an app that is able to receive images shared by other apps. I'm testing the app on my phone.

If i share an image in WhatsApp everything works as expected. My app is listed in the share dialogue and the activity is started. But if try to share an image from any other app (e.g. Photos, Album, Gallery) my app is not listed as on of the options.

I'm using a standard Android Studio project and added only the following lines to the manifest.

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

Why isn't my app listed in the other apps? What do I have to change to make it work?

Upvotes: 0

Views: 1987

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006614

Android is case-sensitive. By having ANDROID.INTENT.CATEGORY.DEFAULT, you will not match any Intent that is seeking android.intent.category.DEFAULT. Change the case to android.intent.category.DEFAULT, and you will match more activity requests.

In fact, since android.intent.category.DEFAULT is added by default to Intent objects passed to startActivity() or startActivityForResult(), I am not quite certain how your activity worked with WhatsApp...

Upvotes: 2

Related Questions