I am having some issues creating a Toast when a BiometricPrompt is canceled by the user.
I am getting the error:
java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare()
Here is my code for the area that this is affecting:
object : BiometricPrompt.AuthenticationCallback()
{
override fun onAuthenticationError(errorCode: Int, errString: CharSequence?) {
super.onAuthenticationError(errorCode, errString)
Toast.makeText(applicationContext, "Authentication Error. Please try again :)", Toast.LENGTH_LONG)
.show()
}
// onAuthSucceeded would be here.
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
Toast.makeText(applicationContext, "Authentication Failed. Please try again :)", Toast.LENGTH_LONG)
.show()
}
}
I have tried adding Looper.prepare() before Toast.makeText, but that doesnt help.
Thanks in advance for your help :)