In Google Plus, the Select Account dialog box appears twice

I embed Google+ through the developer documentation. My methods onConnectionFailed is called after I select an account to log in with a RESOLUTION_REQUIRED error (error code 6). This launches another "Select Account" dialog, which then works (accepts me for permissions) if I select one account. I am not sure why it brings up another dialogue. I start with resolveSignInError Any insight?

In addition, when you select an account from “Select Account”, permissions are displayed, if I click “Cancel” at this point and select another account on the dial, it displays the wrong image for permissions or sometimes there is no image at all. I also got An internal error has occurred toast once.

 @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(); } } } 
+7
android google-plus
source share
3 answers

The following code works fine for me, update it and check.

 private void resolveSignInError() { if (mConnectionResult.hasResolution()) { try { mIntentInProgress = true; mConnectionResult.startResolutionForResult(this, RC_SIGN_IN); } catch (SendIntentException e) { mIntentInProgress = false; mGoogleApiClient.connect(); } } } @Override public void onConnectionFailed(ConnectionResult result) { if (!result.hasResolution()) { GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0).show(); return; } if (!mIntentInProgress) { mConnectionResult = result; if (mSignInClicked) { resolveSignInError(); } } } @Override protected void onActivityResult(int requestCode, int responseCode, Intent intent) { if (requestCode == RC_SIGN_IN) { if (responseCode != RESULT_OK) { mSignInClicked = false; } mIntentInProgress = false; if (!mGoogleApiClient.isConnecting()) { mGoogleApiClient.connect(); } } } 
+1
source share

In "onActivityForResult" you must delete the first line "super.onActivityResult (requestCode, resultCode, data);"

Also, to be sure, do you create your GoogleApiClient in onCreate, plug it in onStart () and unplug it in onStop ()?

Are you calling resolSignInError () from anywhere in your code?

+2
source share

Enter the checkout function in getprofileinformation (). Like this. Hope this code helps you

  private void getProfileInformation() { try { if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) { Person currentPerson = Plus.PeopleApi .getCurrentPerson(mGoogleApiClient); String personName = currentPerson.getDisplayName(); String personPhotoUrl = currentPerson.getImage().getUrl(); String personGooglePlusProfile = currentPerson.getUrl(); String email = Plus.AccountApi.getAccountName(mGoogleApiClient); forget_login_txt.setText(personName+" "+email); Log.e(TAG, "Name: " + personName + ", plusProfile: " + personGooglePlusProfile + ", email: " + email + ", Image: " + personPhotoUrl); personPhotoUrl = personPhotoUrl.substring(0, personPhotoUrl.length() - 2) + PROFILE_PIC_SIZE; signOutFromGplus(); } else { Toast.makeText(getApplicationContext(), "Person information is null", Toast.LENGTH_LONG).show(); } } catch (Exception e) { e.printStackTrace(); } } 
0
source share

All Articles