Android Facebook SDK - 共享对话框不响应取消回拨 [英] Android Facebook SDK - Share dialog does not respond to cancel callback

查看:147
本文介绍了Android Facebook SDK - 共享对话框不响应取消回拨的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用我的Android应用程序的Facebook sdk 4.0,我发现这个问题:



- 当我分享一个帖子,我可以看到facebook界面和我可以发布,完全取消它。我注册了回调,但是如果我按取消按钮,则不调用onCancel回调,该帖子不会发布,而是调用onSuccess回调。但是,如果我触摸关闭按钮,一切都可以正常工作。



这是我的代码:

  private void fbOnShare(){

ShareLinkContent shareContent = new ShareLinkContent.Builder()
.setContentTitle(The Simpson!)
.setContentUrl Uri.parse(http://www.foxplay.com/ar/show/6980-los-simpson?gclid=CPa-7N-y7MUCFYMSHwodNLYAKQ))
.build();


this._btnShare =(ShareButton)findViewById(R.id.share_button);
this._btnShare.setShareContent(shareContent);


_btnShare.registerCallback(this._fbCallbackManager,new FacebookCallback< Sharer.Result>(){
@Override
public void onSuccess(Sharer.Result result){

Log.v(MyApp,分享成功!); //显示如果我按分享或取消按钮

}

@Override
public void onCancel(){
Log.v(MyApp,共享已取消); //仅当我按下关闭按钮
} $ b $时才显示b
@Override
public void onError(FacebookException e){
Log.v(MyApp,Share error:+ e.toString());
}

});
}

_fbCallbackManager是以另一种方法创建的,该方法可以从onCreate方法中的所有内容活动。



http://imgur.com/VbMee31



Cancelar按钮只响应onSuccess回调,不发布共享内容。

解决方案

根据这个这不是一个错误,它应该保持这种方式。



唯一的方式来知道用户接受发布是检查结果的帖子。



如果用户登录后,如果用户没有取消AND,则只有一个postID你的应用程序和它有发布权限。否则它将永远是空的。



是的,我知道这很糟糕。


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 registered the callbacks, but if I press the cancel button, the onCancel callback is not called, the post is not published, but the onSuccess callback is called. However, if I touch the close button, everything works ok.

Here is my code:

 private void fbOnShare(){

    ShareLinkContent shareContent = new ShareLinkContent.Builder()
            .setContentTitle("The Simpson!")
            .setContentUrl(Uri.parse("http://www.foxplay.com/ar/show/6980-los-simpson?gclid=CPa-7N-y7MUCFYMSHwodNLYAKQ"))
            .build();


    this._btnShare = (ShareButton)findViewById(R.id.share_button);
    this._btnShare.setShareContent( shareContent );


    _btnShare.registerCallback( this._fbCallbackManager, new FacebookCallback<Sharer.Result>() {
        @Override
        public void onSuccess(Sharer.Result result) {

            Log.v("MyApp", "Share success!"); //Showed if I press the share or the cancel button

        }

        @Override
        public void onCancel() {
            Log.v("MyApp", "Share canceled"); //Only showed when I press the close button
        }

        @Override
        public void onError(FacebookException e) {
            Log.v("MyApp","Share error: " + e.toString());
        }

    });
}

The _fbCallbackManager is created in another method that initializes everything in the onCreate method from the activity.

http://imgur.com/VbMee31

The "Cancelar" button only respond to the onSuccess callback inspite of does not post the share content. The "close" button works ok.

解决方案

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.

这篇关于Android Facebook SDK - 共享对话框不响应取消回拨的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆