Disable biometry authentication on demand

83 Views Asked by At

I am trying to implement user-defined app locking mechanism with the help of BiometricManager. The app's config has a toggle which allows users to either enable or disable app lock. Once enabled, I want to use new biometric API. This part looks pretty straightforward to me, but I can not find any information about how to reset or disable the biometry settings for an app. This is how I do trigger biometry configuration being setup:

private val enableLock = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
   if (it.resultCode == Activity.RESULT_OK) {
       val value = it.data?.getStringExtra("input")
   }
}
...
val enrollIntent = Intent(Settings.ACTION_BIOMETRIC_ENROLL).apply {
  putExtra(Settings.EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, authentications)
}
enableLock.launch(enrollIntent)

But once this method called on a preconfigured biometry, the resultCode is always RESULT_CANCEL, meaning API itself doesn't allow re-configuration. Any ideas?

0

There are 0 best solutions below