Created
February 19, 2020 18:01
-
-
Save isaidamier/624155fdf36f7cd6f2c37346ee262541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
... | |
private lateinit var biometricPrompt: BiometricPrompt | |
private lateinit var promptInfo: BiometricPrompt.PromptInfo | |
... | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
... | |
biometricPrompt = createBiometricPrompt() | |
promptInfo = createPromptInfo() | |
... | |
} | |
... | |
private fun createPromptInfo(): BiometricPrompt.PromptInfo { | |
val promptInfo = BiometricPrompt.PromptInfo.Builder() | |
// e.g. "Sign in" | |
.setTitle(getString(R.string.prompt_info_title)) | |
// e.g. "Biometric for My App" | |
.setSubtitle(getString(R.string.prompt_info_subtitle)) | |
// e.g. "Confirm biometric to continue" | |
.setDescription(getString(R.string.prompt_info_description)) | |
.setConfirmationRequired(false) | |
.setNegativeButtonText(getString(R.string.prompt_info_use_app_password)) | |
// .setDeviceCredentialAllowed(true) // Allow PIN/pattern/password authentication. | |
// Also note that setDeviceCredentialAllowed and setNegativeButtonText are | |
// incompatible so that if you uncomment one you must comment out the other | |
.build() | |
return promptInfo | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment