I'm writing an image editor in Android. So far it has a single activity. From this activity, I can load an image using a menu option that calls the Gallery activity, and in onActivityResult I treat the received image to paint my canvas so I can edit it. This is working fine.
What I'd like to do now is making this activity callable from anywhere else, so instead of having to pick an image from inside the activity, I could just open the Gallery, pick a photo and send it to my app. But I can't figure out how.
On my manifest, I've put the following inside the <activity>
tags:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
Then, in my activity, as mentioned in http://developer.android.com/training/basics/intents/filters.html , I've put the following inside onCreate():
...
//after initializing my view and stuff
Intent intent =getIntent();
Uri image = intent.getData();
//code to do something with my uri
...
When I install the app in my phone and then open the Gallery, I can pick an image and using the "send" menu and my app will show up in the app list, but when I select it my app opens but ignores the image. It turns out that the uri I'm getting from intent.getData()
is null, and I can't figure out why.
Am I doing anything wrong? Am I forgetting something? If you must know, I'm on stock Android 2.3 using the CoolIris gallery provided with it.