2929import com .google .android .gms .auth .api .credentials .CredentialRequestResponse ;
3030import com .google .android .gms .auth .api .credentials .CredentialsClient ;
3131import com .google .android .gms .auth .api .credentials .IdentityProviders ;
32+ import com .google .android .gms .common .api .CommonStatusCodes ;
3233import com .google .android .gms .common .api .ResolvableApiException ;
3334import com .google .android .gms .tasks .OnCompleteListener ;
3435import com .google .android .gms .tasks .OnFailureListener ;
@@ -121,7 +122,7 @@ public void onCreate(Bundle savedInstance) {
121122 }
122123
123124 @ Override
124- public void onSaveInstanceState (Bundle outState ) {
125+ public void onSaveInstanceState (@ NonNull Bundle outState ) {
125126 // It doesn't matter what we put here, we just don't want outState to be empty
126127 outState .putBoolean (ExtraConstants .HAS_EXISTING_INSTANCE , true );
127128 super .onSaveInstanceState (outState );
@@ -134,19 +135,19 @@ public void onComplete(@NonNull Task<CredentialRequestResponse> task) {
134135 // Auto sign-in success
135136 handleCredential (task .getResult ().getCredential ());
136137 return ;
137- } else {
138- if ( task .getException () instanceof ResolvableApiException ) {
139- ResolvableApiException rae = ( ResolvableApiException ) task . getException ();
138+ } else if ( task . getException () instanceof ResolvableApiException ) {
139+ ResolvableApiException rae = ( ResolvableApiException ) task .getException ();
140+ if ( rae . getStatusCode () == CommonStatusCodes . RESOLUTION_REQUIRED ) {
140141 try {
141142 startIntentSenderForResult (rae .getResolution ().getIntentSender (),
142143 RC_CREDENTIALS_READ );
143144 return ;
144145 } catch (IntentSender .SendIntentException e ) {
145146 Log .e (TAG , "Failed to send Credentials intent." , e );
146147 }
147- } else {
148- Log .e (TAG , "Non-resolvable exception:\n " + task .getException ());
149148 }
149+ } else {
150+ Log .e (TAG , "Non-resolvable exception:\n " + task .getException ());
150151 }
151152 startAuthMethodChoice ();
152153 }
0 commit comments