Reputation: 586
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?
Upvotes: 0
Views: 333
Reputation: 586
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.
Upvotes: 0
Reputation: 6712
I'd say that they messed up the implementation on their side. It's no secret that the Facebook app is not that good.. Your code seems to be allright for me (especially since it works with the Gallery).
Upvotes: 0