【问题标题】:Google+ Share Stopped workingGoogle+ 分享停止工作
【发布时间】:2013-05-23 05:50:06
【问题描述】:

我有一个 android 应用程序,我正在按照these 的说明实施分享。

我设法让它工作。第二天我又回来了,我在 logcat 中得到了这个输出:

 G+ on connection failed ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{422d8470: android.os.BinderProxy@422d8410}}

我已经三次检查了 api 控制台,删除了我的 OAuth 客户端 ID 并重新输入。这还没有解决。知道我可以研究什么来解决它吗?

【问题讨论】:

    标签: android google-plus


    【解决方案1】:

    由于多种原因,您可以获得 SIGN_IN_REQUIRED 连接结果,例如:

    • 如果您致电PlusClient.clearDefaultAccount();
    • 如果您通过http://plus.google.com/apps 或致电PlusClient.revokeAccessAndDisconnect(); 断开应用。
    • 如果您的应用在之前请求的范围之外还请求授权范围。

    对于 SIGN_IN_REQUIRED,您收到的 ConnectionResult 包含可用于解决问题的 PendingIntent。在the instructions you're following 的示例中,示例代码使用以下代码处理onConnectionFailed 中的错误:

    @Override
    public void onConnectionFailed(ConnectionResult result) {
        if (result.hasResolution()) {
            try {
                result.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
            } catch (SendIntentException e) {
                mPlusClient.connect();
            }
        }
        // Save the result and resolve the connection failure upon a user click.
        mConnectionResult = result;
    }
    

    result.startResolutionForResult() 将显示帐户选择器或权限对话框以解决上述问题,并将控制权返回给onActivityResult,例如:

    @Override
    protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
        if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
            mConnectionResult = null;
            mPlusClient.connect();
        }
    }
    

    此时对PlusClient.connect() 的调用应该会成功。

    【讨论】:

    • 我用你的版本替换了onConnectionFailed,现在可以正常工作了,谢谢
    • @Lee,正确的解决方案,但收到一条消息“发生内部错误”。您对此有什么想法。提前致谢...
    • @jagdish - 尝试启用详细日志记录并查看 LogCat 中显示的内容。在命令行上运行: adb shell setprop log.tag.GooglePlusPlatform VERBOSE
    • @Lee 我们应该将 REQUEST_CODE_RESOLVE_ERR 设置为什么?谢谢
    • @superuser REQUEST_CODE_RESOLVE_ERR 可以是任何整数常量。您的 Activity 可能有几个点开始执行结果的意图,所有这些都返回到 onActivityResult。 REQUEST_CODE_RESOLVE_ERR 可帮助您将开始解决登录错误的意图与您可能开始的其他意图区分开来。
    猜你喜欢
    • 2014-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-18
    • 1970-01-01
    • 2013-02-26
    • 2013-06-30
    • 1970-01-01
    相关资源
    最近更新 更多