Posting photo from a native ShareDialog in Facebook android SDK

时光毁灭记忆、已成空白 提交于 2019-12-23 11:05:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!