Skip to content

Instantly share code, notes, and snippets.

@vinodbaste
Created May 7, 2022 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinodbaste/48f5bfa7d7dd2eed253d8b378065dab9 to your computer and use it in GitHub Desktop.
Save vinodbaste/48f5bfa7d7dd2eed253d8b378065dab9 to your computer and use it in GitHub Desktop.
fun setBiometricPromptInfo(
title: String,
subtitle: String,
description: String,
allowDeviceCredential: Boolean
): BiometricPrompt.PromptInfo {
val builder = BiometricPrompt.PromptInfo.Builder()
.setTitle(title)
.setSubtitle(subtitle)
.setDescription(description)
// Use Device Credentials if allowed, otherwise show Cancel Button
builder.apply {
if (allowDeviceCredential) setDeviceCredentialAllowed(true)
else setNegativeButtonText("Cancel")
}
return builder.build()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment