问题
I am trying to post an image to the Facebook using SDK v3.6 ShareDialog.
As a result I got com.facebook.FacebookException: Error retrieving image attachment.
I did just like Doc says:
private void ShareDialog(){
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
//action.setProperty("game", "https://example.com/cooking-app/meal/Lamb-Vindaloo.html");
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
List<Bitmap> images = new ArrayList<Bitmap>();
images.add(bitmap);
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, action, "cooking-app:cook", "game")
.setImageAttachmentsForAction(images, true)
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
And I know I need to add <provider android:authorities="com.facebook.app.NativeAppCallContentProvider{Facebook-app-id}"
android:name="com.facebook.NativeAppCallContentProvider" />
in AndroidManifest.xml, but when I did this, there is an error code, Multiple annotations found at this line:
- Tag <provider> attribute authorities has invalid character '{'.
- Exported content providers can provide access to potentially sensitive
data
How to add a provider correctly?
回答1:
In your provider
definition, where it says {Facebook-app-id}
you have to fill in the app id provided to by Facebook.
回答2:
Add the content provider to your manifest.
<provider
android:name="com.facebook.NativeAppCallContentProvider"
android:authorities="com.facebook.app.NativeAppCallContentProvider{Facebook-App-Id}"
android:exported="true" />
Make sure exported= true (as above)
来源:https://stackoverflow.com/questions/21227559/posting-photo-from-a-native-sharedialog-in-facebook-android-sdk