Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Posting photo from a native ShareDialog in Facebook android SDK

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?

like image 917
user2968423 Avatar asked Jan 20 '14 06:01

user2968423


2 Answers

In your provider definition, where it says {Facebook-app-id} you have to fill in the app id provided to by Facebook.

like image 161
ianhanniballake Avatar answered Oct 01 '22 14:10

ianhanniballake


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)

like image 36
Dhruv Avatar answered Oct 01 '22 16:10

Dhruv