How to solve "Failed to connect" on Google+ to enter Android?

I recently made a Google+ login code. I need to allow Google+ registration to the user from the page and transfer the control to the next page using Intent. Here is what i did

if (view == imageViewgoogleplus) { str_button_clicked = "googleplus"; dogoogleLogin(); } private void dogoogleLogin() { mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(Plus.API) .addApi(Plus.API, Plus.PlusOptions.builder().build()) .addScope(Plus.SCOPE_PLUS_LOGIN).build(); mGoogleApiClient.connect(); signInWithGplus(); } private void signInWithGplus() { if (!mGoogleApiClient.isConnecting()) { mSignInClicked = true; resolveSignInError(); } } 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 onConnectionSuspended(int value) { mGoogleApiClient.connect(); } @Override public void onConnectionFailed(ConnectionResult connectionresult) { System.out.println("Connection failed"); if (!connectionresult.hasResolution()) { GooglePlayServicesUtil.getErrorDialog( connectionresult.getErrorCode(), this, 0).show(); return; } if (!mIntentInProgress) { mConnectionResult = connectionresult; if (mSignInClicked) { resolveSignInError(); } } } @Override public void onConnected(Bundle bundle) { mSignInClicked = false; getProfileInformation(); } private void getProfileInformation() { try { if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) { Person currentPerson = Plus.PeopleApi .getCurrentPerson(mGoogleApiClient); String personName = currentPerson.getDisplayName(); String email = Plus.AccountApi.getAccountName(mGoogleApiClient); } } catch (Exception e) { e.printStackTrace(); } } 

When I run the code, it should get the credentials from the user mobile, and then he should make a login. I keep getting a connection with Google. I configured SHA1 correctly and I also provided the correct permissions in the manifest file. However, I cannot understand the problem. Please help.

+5
source share

Source: https://habr.com/ru/post/1214136/


All Articles