in CredentialsSignIn/app/src/main/java/com/google/example/credentialssignin/MainActivity.java [247:276]
private void saveCredential(Credential credential) {
if (credential == null) {
Log.w(TAG, "Ignoring null credential.");
return;
}
mCredentialsClient.save(mCredential).addOnCompleteListener(
new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "save:SUCCESS");
return;
}
Exception e = task.getException();
if (e instanceof ResolvableApiException) {
// Saving the credential can sometimes require showing some UI
// to the user, which means we need to fire this resolution.
ResolvableApiException rae = (ResolvableApiException) e;
resolveResult(rae, RC_CREDENTIALS_SAVE);
} else {
Log.w(TAG, "save:FAILURE", e);
Toast.makeText(MainActivity.this,
"Unexpected error, see logs for detals",
Toast.LENGTH_SHORT).show();
}
}
});
}