Android Facebook Sdk - Share Dialog Does Not Respond To Cancel Callback
I'm working with Facebook sdk 4.0 on my android app and I found this problem: -when I share a post, I can see the facebook interface and I can post it and cancel it perfectly. I re
Solution 1:
According to THIS it is not a bug and it should stay that way.
The only way to know if the user accepted the publishing is to check for the postID on the result.
You will only have a postID if the user didn't cancel AND if the user is logged in to your app AND it has publish permissions. Otherwise it will always be null.
Yeah I know, it sucks.
Solution 2:
privatebooleanhasPublishPermission()
{
AccessToken accessToken = AccessToken.getCurrentAccessToken();
return accessToken != null && accessToken.getPermissions().contains("publish_actions");
}
privatevoidpostStatusUpdate()
{
if(hasPublishPermission())
{
Log.d("PostStatus", "Ist");
Profile profile = Profile.getCurrentProfile();
ShareLinkContent linkContent = newShareLinkContent.Builder()
.setContentTitle("Hello Facebook")
.setContentDescription( "The 'Hello Facebook' sample showcases simple Facebook integration")
.setContentUrl(Uri.parse("http://developers.facebook.com/docs/android"))
.build();
if(ShareDialog.canShow(ShareLinkContent.class))
{
Log.d("PostStatus", "2nd");
ShareDialog shareDialog = newShareDialog(instance);
shareDialog.registerCallback(callbackManager, shareCallback);
}
elseif (profile != null)
{
Log.d("PostStatus", "3rdt");
ShareApi.share(linkContent, shareCallback);
}
}
else
{
LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList("publish_actions"));
}
}
privateFacebookCallback<Sharer.Result> shareCallback = newFacebookCallback<Sharer.Result>()
{
@OverridepublicvoidonSuccess(Result result) {
// TODO Auto-generated method stub
}
@OverridepublicvoidonError(FacebookException error) {
// TODO Auto-generated method stub
}
@OverridepublicvoidonCancel() {
// TODO Auto-generated method stub
}
};
Post a Comment for "Android Facebook Sdk - Share Dialog Does Not Respond To Cancel Callback"