Unable to share photo in Facebook

Viewed 21

I am taking a photo using an Android phone, and I want to post it in Facebook. My code:

private void SharePhotoFacebook(Bitmap bmp) {
    FacebookSdk.sdkInitialize(FaceActivity.this);
    // Create a callbackManager to handle the login responses.
    callbackManager = CallbackManager.Factory.create();

    shareDialog = new ShareDialog(this);

    SharePhoto photo = new SharePhoto.Builder()
            .setBitmap(bmp)
            .build();
    if(ShareDialog.canShow(SharePhotoContent.class)){
        SharePhotoContent content = new SharePhotoContent.Builder()
                .addPhoto(photo)
                .build();
        shareDialog.show(content);
    }

    // this part is optional
    shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {
            Log.i("David", "Éxito");
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {
            Log.i("David", "Error");
        }
    });
}

But no dialog is showing, and nothing is posted in Facebook. I have implemented this code in the same Activity I take photo (FaceActivity), and is the Activity declared in Facebook Developer page of the app. What is wrong?

I can see like something tries to show (a grey "flash" that appears in the screen) but nothing shows.

EDIT: Im taking photo this way:

makePhoto.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mCameraSource.takePicture(null, new CameraSource.PictureCallback() {
                @Override
                public void onPictureTaken(@NonNull byte[] bytes) {
                    Log.i("David", String.valueOf(bytes.length));
                    bmp= BitmapFactory.decodeByteArray(bytes,0,bytes.length);
                    ShowShareDialog();
                    //SharePhotoFacebook(bmp);
                }
            });
        }
    });

I just realized I have this in my debug:

Unsupported get request. Object with ID 'XXXXXXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api [extra]: 
0 Answers
Related