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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With