How to post a photo using the Facebook app from another Android app

I am using the below code. It opens the Facebook Messenger app, but the image is not displayed (with a broken image) and the upload fails.

List<Bitmap> abc = new ArrayList<Bitmap>();
abc.add(pic);
FacebookDialog.PhotoMessageDialogBuilder builder = new FacebookDialog.PhotoMessageDialogBuilder(LocationShare.this);
builder.addPhotos(abc);
builder.build().present();

      

Is there a problem with how I add photos? i mean using list i mentioned content provider in android manifest.xml i can submit link using below code.

FacebookDialog.MessageDialogBuilder builder = new FacebookDialog.MessageDialogBuilder (getActivity ()) .setLink (" https://developers.facebook.com/docs/android/share/ ") .setName ("Message Dialog Dialog Box") .setCaption (" Create great social apps that attract your friends "). .setPicture (" http://i.imgur.com/g3Qc1HN.png ") .setDescription ("Allow your users to link to posts from your application using the Android SDK.");

+3


source to share


1 answer


Have you added a content provider?

If you look at the javadocs for addPhotos ( https://developers.facebook.com/docs/reference/android/current/class/FacebookDialog.PhotoMessageDialogBuilder/#addPhotos ) it says that you need to specify NativeAppCallContentProvider in your AndroidManifest.



The docs for NativeAppCallContentProvider ( https://developers.facebook.com/docs/reference/android/current/class/NativeAppCallContentProvider/ ) talk about how to add a content provider.

You can also view the HelloFacebook sample, which has an example of adding a content provider to an AndroidManifest.

+2


source







All Articles