signInWithSavedCredentials
Attempts to sign in using credentials saved in Android's Credential Manager.
This method leverages Android's Credential Manager API to retrieve saved credentials (email/password or Google account) and authenticate the user automatically. This enables seamless "one-tap" sign-in without requiring the user to re-enter credentials.
Behavior
Shows the Credential Manager UI with saved credentials
User selects a saved credential to sign in
Authenticates with Firebase using the selected credential
Saves/updates the credential in Credential Manager after successful sign-in
Requirements
Requires an Activity context for showing the credential picker UI
Credentials must have been previously saved via Credential Manager
User must have at least one saved credential
Exceptions
Throws
CancellationExceptionif user cancels the credential pickerThrows
NoCredentialExceptionif no saved credentials are foundThrows
FirebaseAuthExceptionif authentication with saved credentials fails
Example
// In your login ViewModel
fun autoSignIn() {
_uiState.updateStateWith {
authRepository.signInWithSavedCredentials(activity)
}
}Return
The authenticated AuthUser upon successful sign-in
Parameters
The activity instance required for showing the credential picker UI
Throws
if the user cancels the operation
for authentication failures