2013-05-28 107 views
9

我有一个Android应用程序,我正在执行分享以下these说明。Google+分享停止工作

我设法让它工作。我回来给它的第二天,我得到这个输出的logcat:

G+ on connection failed ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{422d8470: [email protected]}} 

我有三重检查API控制台,打消了我的OAuth clientID的和重新输入新鲜。这并没有解决它。任何关于我可以研究解决它的想法?

回答

10

如果你打电话PlusClient.clearDefaultAccount();你可以得到SIGN_IN_REQUIRED连接结果的原因很多,如:

  • 如果您通过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()应该成功。

+1

我用你的版本替换了连接失败,并且现在工作正常,谢谢 – serenskye

+0

@Lee,正确的解决方案,但得到一个敬酒信息“内部错误发生”。对你有这个想法。提前感谢... – jagdish

+0

@jagdish - 尝试启用详细日志记录并查看LogCat中显示的内容。在命令行上运行: adb shell setprop log.tag.GooglePlusPlatform VERBOSE – Lee