如果你打电话PlusClient.clearDefaultAccount();
你可以得到SIGN_IN_REQUIRED连接结果的原因很多,如:
对于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()
应该成功。
来源
2013-05-28 12:03:07
Lee
我用你的版本替换了连接失败,并且现在工作正常,谢谢 – serenskye
@Lee,正确的解决方案,但得到一个敬酒信息“内部错误发生”。对你有这个想法。提前感谢... – jagdish
@jagdish - 尝试启用详细日志记录并查看LogCat中显示的内容。在命令行上运行: adb shell setprop log.tag.GooglePlusPlatform VERBOSE – Lee