我正在通過開發者文檔實施Google+登錄。在我選擇要登錄的帳戶並使用錯誤RESOLUTION_REQUIRED
(錯誤代碼6)之後,我的onConnectionFailed
方法正在被調用。這將啓動另一個「選擇一個帳戶」對話框,然後運行(帶我去權限),如果我選擇相同的帳戶。我不確定爲什麼會提示另一個對話框。我從resolveSignInError
開始任何見解?谷歌加登錄「選擇帳戶」對話框出現兩次
此外,從「選擇帳戶」中選擇一個帳戶將顯示權限,如果我在該點擊取消並從撥號中選擇另一個帳戶,則會顯示錯誤的權限圖像或根本沒有圖像。我也得到An internal error has occurred
烤麪包一次。
@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();
}
}
}
謝謝。我有一個super.onActivityForResult()並將其刪除(僅當我不處理結果時才調用它)解決了問題。 – Ridcully 2015-12-19 18:05:43