Google 加上 'choose account' 选择帐户在取消时不会消失?

Google plus 'choose account' choose account does not disappears on cancel?

我正在尝试使用 google plus 登录并且它有效 fine.I 有多个帐户与我的帐户相关联,所以它显示弹出窗口以选择帐户但是当我点击然后取消按钮 disappears.It 一次又一次出现。告诉我方法怎么做?

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
     if (requestCode == RC_SIGN_IN) 
     {
         Log.i("RAE","Result is  ");
            if (resultCode != RESULT_OK) {
              mSignInClicked = false;
            }

            mIntentInProgress = false;

            if (!mGoogleApiClient.isConnecting()) {
              mGoogleApiClient.connect();
            }
          }


}

连接失败

@Override
    public void onConnectionFailed(ConnectionResult result) {
        // TODO Auto-generated method stub
         if (!mIntentInProgress && result.hasResolution()) {
                try {
                  mIntentInProgress = true;
                  startIntentSenderForResult(result.getResolution().getIntentSender(),
                      RC_SIGN_IN, null, 0, 0, 0);
                } catch (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();
                }
              }

    }

您没有使用 mSignInClicked 的值来确定是否要 startIntentSenderForResult() - 这意味着即使用户单击取消按钮,您仍然会调用 startIntentSenderForResult()一次又一次-将 mSignInClicked 添加到您的 if 语句:

if (!mIntentInProgress && mSignInClicked && result.hasResolution()) {

如果您仍然希望在首次启动时获得类似自动登录的体验,您还应该在 onCreate() 中将 mSignInClicked 设置为 true if savedInstanceState == null (即 activity 第一次启动)。这将确保每次用户启动 activity 时至少执行一次 startIntentSenderForResult()。注意:您可能还想设置一个 shared preference 说明您尝试自动登录,如果您已经尝试自动登录但他们取消了,则不会再次尝试自动登录。