question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Authenticating with BiometricPrompt during OnResume()

See original GitHub issue

Xamarin.Android Version (eg: 6.0):

9.0

Operating System & Version (eg: Mac OSX 10.11):

Winsdows 10

Support Libraries Version (eg: 23.3.0):

AndroidX v1.0.0-rc1

Describe your Issue:

W/BiometricPromptCompat( 5060): Not launching prompt. authenticate() called after onSaveInstanceState()

Calling the Biometric Prompt during OnResume() dismisses the dialog with an error saying that the prompt cannot be launched after onSaveInstanceState() has been called.

Wrapping the call to BiometricManager in a fragment transaction with CommitAllowingStateLoss() also does not have any effect

Steps to Reproduce (with link to sample solution if possible):

Calling the Biometric Prompt during OnResume()

        public async Task<bool> Authenticate(CancellationToken cancellationToken)
        {
            var promptInfo = new BiometricPrompt.PromptInfo.Builder()
                .SetTitle("Login")
                .SetNegativeButtonText("Cancel")
                .Build();

            var activity = _activityResolver();
            var executor = Executors.NewSingleThreadExecutor();
            var handler = new BiometricsAuthenticationHandler();

            using var dialog = new BiometricPrompt((FragmentActivity) activity, executor, handler);
            await using (cancellationToken.Register(() => dialog.CancelAuthentication()))
            {
                dialog.Authenticate(promptInfo);
                return await handler.Task;
            }
        }

Include any relevant Exception Stack traces, build logs, adb logs:

W/BiometricPromptCompat( 5060): Not launching prompt. authenticate() called after onSaveInstanceState()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
moljaccommented, Feb 5, 2020

And thanks - I did have a good day. Finished Material 1.1.0 bindings (recently released by google).

1reaction
moljaccommented, Feb 5, 2020

@bradleygunn

Would you be so kind and create minimal sample, so we can add it to the samples, please?

Short readme would be even greater.

That would help other users a lot. Thanks.

And of course you could close this issue yourself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Biometric Prompt in onResume throws FragmentManager ...
I resolved the issue by calling the biometric prompt on fragment instead of activity. The change was biometricPrompt = BiometricPrompt(this ...
Read more >
Login with Biometrics on Android
Biometric login provides a convenient method for authorizing access to private content within your app. Instead of having to remember an account username...
Read more >
How To Make A Login Activity With Biometrics Support On ...
User can then click the biometric login button to bring up a platform-specific dialog, and go through the biometric authentication process to ...
Read more >
A Guide to Implement Biometric Authentication
This function first checks if the device can authenticate using biometric or not. If it does, it creates a BiometricPrompt for encryption and ......
Read more >
BiometricPrompt.java
A class that manages a system-provided biometric prompt. On devices running Android 9.0 (API ... An error code that may be returned during...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found