Search code examples
androidfacebookfacebook-sdk-4.0

Facebook ShareDialog - Doesn't shows up on sharePhotoContent


I have added all the content provider's in the AndroidManifest.xml.

ShareDialog with ShareLinkContent is working fine but while trying to upload the photo it isn't working. Nothing Happens, doesn't displays any dialog.

Uri uri1 = Uri.parse("file://" + path);
    Bitmap bitmap=null;

    try {
        bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri1);
    } catch (Exception e) {
      // TODO: handle exception
        e.printStackTrace();
    }

    //bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_launcher);

    SharePhoto photo = new SharePhoto.Builder()
            .setBitmap(bitmap)
            .build();

    ArrayList<SharePhoto> photos = new ArrayList<>();
    photos.add(photo);

    if (ShareDialog.canShow(SharePhotoContent.class)) {
        SharePhotoContent content = new SharePhotoContent.Builder()
                .setPhotos(photos)
                .setContentUrl(Uri.parse("http://www.bakarapp.com/app/"))
                .build();


        shareDialog.show(content);
    }

Solution

  • After reporting the bug to Facebook, I got their help in rectifying my code.

    The real problem seems to be that I was setting both a photo and a content URL, that doesn't make sense when sharing a photo. Just set the photo in the SharePhotoContent and the share dialog will be correctly shown

     if (ShareDialog.canShow(SharePhotoContent.class)) {
        SharePhotoContent content = new SharePhotoContent.Builder()
                .setPhotos(photos)
                .build();
    
        shareDialog.show(content);
    }