Skip to content

Instantly share code, notes, and snippets.

@tdcolvin
Created February 22, 2023 17:02
Show Gist options
  • Save tdcolvin/f7ce1112eb6b35920de7e8addeb967d5 to your computer and use it in GitHub Desktop.
Save tdcolvin/f7ce1112eb6b35920de7e8addeb967d5 to your computer and use it in GitHub Desktop.
fun signInWithSavedCredential(activity: Activity) {
viewModelScope.launch {
try {
val passwordCredential = getCredential(activity) ?: return@launch
val signInSuccess = true
//Run your app's sign in logic using the returned password credential
// signInSuccess = doSomeSignInWork(username, password)
//then if successful...
if (signInSuccess) {
//Indicate to the UI that we're now signed in.
signedInPasswordCredential.value = passwordCredential
}
}
catch (e: Exception) {
Log.e("CredentialTest", "Error getting credential", e)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment