29
29
import com .google .android .gms .auth .api .credentials .CredentialRequestResponse ;
30
30
import com .google .android .gms .auth .api .credentials .CredentialsClient ;
31
31
import com .google .android .gms .auth .api .credentials .IdentityProviders ;
32
+ import com .google .android .gms .common .api .CommonStatusCodes ;
32
33
import com .google .android .gms .common .api .ResolvableApiException ;
33
34
import com .google .android .gms .tasks .OnCompleteListener ;
34
35
import com .google .android .gms .tasks .OnFailureListener ;
@@ -121,7 +122,7 @@ public void onCreate(Bundle savedInstance) {
121
122
}
122
123
123
124
@ Override
124
- public void onSaveInstanceState (Bundle outState ) {
125
+ public void onSaveInstanceState (@ NonNull Bundle outState ) {
125
126
// It doesn't matter what we put here, we just don't want outState to be empty
126
127
outState .putBoolean (ExtraConstants .HAS_EXISTING_INSTANCE , true );
127
128
super .onSaveInstanceState (outState );
@@ -134,19 +135,19 @@ public void onComplete(@NonNull Task<CredentialRequestResponse> task) {
134
135
// Auto sign-in success
135
136
handleCredential (task .getResult ().getCredential ());
136
137
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 ) {
140
141
try {
141
142
startIntentSenderForResult (rae .getResolution ().getIntentSender (),
142
143
RC_CREDENTIALS_READ );
143
144
return ;
144
145
} catch (IntentSender .SendIntentException e ) {
145
146
Log .e (TAG , "Failed to send Credentials intent." , e );
146
147
}
147
- } else {
148
- Log .e (TAG , "Non-resolvable exception:\n " + task .getException ());
149
148
}
149
+ } else {
150
+ Log .e (TAG , "Non-resolvable exception:\n " + task .getException ());
150
151
}
151
152
startAuthMethodChoice ();
152
153
}
0 commit comments