I've been dealing with Google+ login on android lately, and one thing keeps bugging me.
In all of their officially sanctioned examples, there isn't a method that specifically shows the Login process. The method that is called every time you try to log someone in is called resolveSignInError() shown here:
private void resolveSignInError() {
if (mConnectionResult.hasResolution()) {
try {
mIntentInProgress = true;
mConnectionResult.startResolutionForResult(this, RC_SIGN_IN);
Log.d("mGoogleApiClient ", mGoogleApiClient.toString());
} catch (IntentSender.SendIntentException e) {
mIntentInProgress = false;
mGoogleApiClient.connect();
}
}
}
This method also relies on the fact that there is a mConnectionResult, which is set in the on connection failure method
public void onConnectionFailed(ConnectionResult result) {
if (!result.hasResolution()) {
GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this,
0).show();
return;
}
if (!mIntentInProgress) {
// Store the ConnectionResult for later usage
mConnectionResult = result;
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();
}
}
}
So the entire scheme revolves around having already failed to login at least once. Does anyone know why there isn't a method that directly logs you into google plus? Why does this make sense as a way to structure readable software?