I'm creating an authentication service where the user must use the fingerprint sensor of the smartphone. I saw that android uses the BiometricPrompt APIs, but there's only one problem: I don't know how to set a timeout that dismisses the dialog after a certain amount of time (the dialog is always on utile the user cancels it or uses the fingerprint). Does anyone know how can I do it?
I've tried modifying the executor parameter of the authentication method, but it seems that the executor is not called.
EDIT
I've updated the code using @Subham Naik advice
timeOutHandler = new Handler();
timeOutHandler.postDelayed(new Runnable() {
@Override
public void run() {
mBiometricManager.cancelAuthentication();
}
} ,4000);
But it works only on the first prompt: after the dialog goes off, the second time it stays on.
If you want to cancel the authentication
have you tried with
{biometricPromptObject}.cancelAuthentication()