我正在通过开发者文档实现 Google+ 登录。在我选择要登录的帐户时出现错误 RESOLUTION_REQUIRED
(错误代码 6)后,将调用我的 onConnectionFailed
方法。这将启动另一个“选择帐户”对话框,如果我选择相同的帐户,该对话框将起作用(带我进入权限)。我不确定为什么它会提示另一个对话框。我从 resolveSignInError
开始,有什么见解吗?
此外,从“选择一个帐户”中选择一个帐户会显示权限,如果我此时点击取消并从拨号盘中选择另一个帐户,它会显示错误的权限图片,有时甚至根本没有图片。我还收到了一次 An internal error has occurred
toast。
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
if (!mIntentInProgress) {
// Store the ConnectionResult so that we can use it later when the user clicks
// 'sign-in'.
mConnectionResult = connectionResult;
if (mSignInClicked) {
// The user has already clicked 'sign-in' so we attempt to resolve all
// errors until the user is signed in, or they cancel.
resolveSignInError();
}
}
}
private void resolveSignInError() {
if (mConnectionResult != null && mConnectionResult.hasResolution()) {
try {
mIntentInProgress = true;
startIntentSenderForResult(mConnectionResult.getResolution().getIntentSender(),
RC_SIGN_IN, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
// The intent was canceled before it was sent. Return to the default
// state and attempt to connect to get an updated ConnectionResult.
mIntentInProgress = false;
mGoogleApiClient.connect();
}
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
if (resultCode != RESULT_OK) {
mSignInClicked = false;
}
mIntentInProgress = false;
if (!mGoogleApiClient.isConnecting()) {
mGoogleApiClient.connect();
}
}
}
最佳答案
在“onActivityForResult”中,你应该删除第一行“super.onActivityResult(requestCode, resultCode, data);”
另外,为了确定,您在 onCreate 中创建 GoogleApiClient,在 onStart() 中连接它并在 onStop() 中断开连接?
您是否从代码中的其他任何地方调用 resolveSignInError()?
关于android - Google Plus 登录 'Choose an Account' 对话框出现两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26640735/