Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

facebook android sdk sharedialog callback is always success

Using Facebook android sdk version 4.1.1, I managed to open a shareDialog and share a content using the below code:

if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setContentTitle("Hello Facebook")
                .setContentDescription(
                        "The 'Hello Facebook' sample  showcases simple Facebook integration")
                .setContentUrl(Uri.parse("http://developers.facebook.com/android"))
                .build();

        shareDialog.show(linkContent);
        shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {

            @Override
            public void onSuccess(Result result) {
                //always gets called

            }

            @Override
            public void onCancel() {
                //do something

            }

            @Override
            public void onError(FacebookException error) {
                // TODO Auto-generated method stub

            }

        });
    }

and the callback on ActivityResult code:

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    callbackManager.onActivityResult(requestCode, resultCode, data);
}

the resultCode is always -1 which is RESULT_OK regardless whether user pressed back or post button of the dialog. and the callback's onSuccess function is always called and the postId is always null regardless whether the content is posted or cancelled. Anyone know why is it acting this way?

like image 868
arash moeen Avatar asked Nov 01 '22 04:11

arash moeen


1 Answers

According to THIS which is a reported bug on facebook developers bug section, this is known and according to the answers given, it seems it's in the design that any form of closing the dialog is considered as success.

like image 65
arash moeen Avatar answered Nov 13 '22 20:11

arash moeen