I’m trying to implement the PICK intent-filter, and so far I’ve got them in the context menu, but how do I respond back to whoever started the app that way?
Lets say I have the activity:
<activity
android:name="ListActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
Now I start this activity through Facebook by sharing a photo and selecting my own app to get it, I have the following code:
File f = new File(Environment.getExternalStorageDirectory(), "image.jpg");
Uri uri = Uri.fromFile(f);
if(f.exists()) System.out.println("exists");
Intent data = new Intent();
data.setData(uri);
setResult(RESULT_OK, data);
finish();
However nothing happens in the Facebook app (which is where I’m currently testing my implementation). If I instead use the “Share photo” from Facebook again, but use the Gallery app to choose an image, that works as I want my app to work.
What have I done wrong?
After researching this closer I’ve figured that the problem is in the scheme of the Uri. You cannot pass a Uri with the file-scheme (“file://…”) to the Facebook app. It does nothing. Instead, if you use the content-scheme (“content://…”) to address the same image, it works perfectly.
How to convert between those two is separate problem.