简体   繁体   English

facebook android SSO完成,但活动关闭而不调用onActivityResult()

[英]facebook android SSO completes, but activity closes without calling onActivityResult()

The problem I'm having is as the title suggests. 正如标题所示,我遇到的问题。 I make the authorize() call but am never able to call authorizeCallback() because onActivityResult() is never called. 我进行了authorize()调用,但我永远无法调用authorizeCallback(),因为从不调用onActivityResult()。 SSO does complete, because it shows the permissions screen (with Don't Allow/Allow) and the app approval is shown on my Facebook settings page. SSO确实完成,因为它显示了权限屏幕(不允许/允许),并且我的Facebook设置页面上显示了应用程序批准。 Any ideas? 有任何想法吗? I thought it might have something to do with the launchMode of the activity, but removed "singleInstance" and it didn't make a difference. 我认为它可能与活动的launchMode有关,但删除了“singleInstance”并且没有任何区别。

As I mentioned above, I can confirm the permissions activity is started in Facebook.java. 正如我上面提到的,我可以确认权限活动是在Facebook.java中启动的。

 try {
        Log.e("@@@", "Starting activity");
        activity.startActivityForResult(intent, activityCode);
    } catch (ActivityNotFoundException e) {
        didSucceed = false;
    }

For what it's worth, I can confirm the code used below. 对于它的价值,我可以确认下面使用的代码。

I've implemented the authorizeCallback() method in onActivityResult(): 我在onActivityResult()中实现了authorizeCallback()方法:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    mStateHolder.getFacebook().authorizeCallback(requestCode, resultCode, data);
}

.. but it's never called. ..但它永远不会被召唤。 The authorize method I've used is as follows: 我使用的授权方法如下:

facebook.authorize(this, new String[]{ "user_birthday" }, new DialogListener() {
        public void onComplete(Bundle values) {
            Log.e(TAG, "onComplete()");
            // I make a request here..
        }
        // ...with the other methods as well
}

Other potentially useful info: 其他可能有用的信息:

  • I'm running a Nexus One, 2.3.4 我正在运行Nexus One,2.3.4
  • The Facebook app is installed Facebook应用程序已安装
  • It works fine if I force the Dialog method, but I'm trying to get SSO working. 如果我强制使用Dialog方法,它可以正常工作,但我正在尝试让SSO正常工作。
  • EDIT: Urgh! 编辑:呃! After much searching, I found the problem. 经过多次搜索,我发现了问题。 There was a rogue Intent.FLAG_ACTIVITY_NO_HISTORY flag in the intent (which doesn't keep the activity in the stack). 在intent中有一个流氓Intent.FLAG_ACTIVITY_NO_HISTORY标志(它不会将活动保留在堆栈中)。 Thanks everyone for attempting to answer this. 谢谢大家试图回答这个问题。

    EDIT2: removing launchMode=singleInstance does make a difference too btw.. I started getting the error "Failed to read calling package's signature". EDIT2:删除launchMode = singleInstance确实有所作为btw ..我开始收到错误“无法读取调用包的签名”。

    How are you finishing your authentication activity? 您是如何完成身份验证活动的? You have to set the Result type and maybe send a value back. 您必须设置结果类型并可能返回值。 eg: 例如:

    Intent data = new Intent();
    data.putExtra(ApplicationConstants.EXTRA_IS_DONE, true);
    setResult(RESULT_OK, data);
    finish();
    

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM