1
votes

I'm implementing Facebook sharing feature in my app. I took the code from the example https://developers.facebook.com/docs/sharing/android (Share Dialog)

FacebookCallback is implementing 3 methods onSuccess, onCancel, onError.

   shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {
            Timber.e("onSuccess " + result.getPostId());
        }

        @Override
        public void onCancel() {
            Timber.e("onCancel");

        }

        @Override
        public void onError(FacebookException e) {
            Timber.e("onError");
        }
    });

I want to know if user cancels share dialog instead of sharing content. But for some reasons onSuccess is called and result.getPostId() is null in both cases if user successfully shares content or cancels dialog. Why onCancel isn't called if user pressed back and why result.getPostId() is null even if post was shared successfully?

1

1 Answers

2
votes

You will only get onCancel if the user has authorized your app (i.e. logged into Facebook via your app).

You will only get the postId if your app also has the publish_actions permission.

See https://developers.facebook.com/docs/android/troubleshooting#onsuccess