I cannot detect the cancellation in the password addition in FingerPrint

15 views
Skip to first unread message

rdvg...@gmail.com

unread,
Jul 10, 2021, 12:43:31 PM7/10/21
to CodenameOne Discussions
Hi,

I am testing with the example that is in github, I changed the add method and I cannot detect the cancellation.

Code:
        addItem.addActionListener(evt -> {
            if (!Fingerprint.isAvailable()) {
                ToastBar.showErrorMessage("Fingerprint not avaiable on this platform");
                return;
            }
            AsyncResource<Boolean> r = Fingerprint.addPassword("Adding secure item to keystore", keyName.getText(), keyValue.getText());
            if (r.isCancelled()) {
                Dialog.show("Error", "Cancelled process", "Continuar", null);
            }
        });

Thanks

Shai Almog

unread,
Jul 11, 2021, 3:36:38 AM7/11/21
to CodenameOne Discussions
Hi,
is the callback invoked at all? You can show a toast if it is. Are we talking about Android here?

rdvg...@gmail.com

unread,
Jul 11, 2021, 11:32:07 AM7/11/21
to CodenameOne Discussions
Hi,

Thanks for answering.
In the end I was able to solve by changing the code as follows:
                        if (u.seguridadBiometrica.get() && Fingerprint.isAvailable()) {
                            Fingerprint.addPassword(idioma.getMensaje77(), "TEMPUS_KEY", Long.toString(System.currentTimeMillis())).onResult((success, err) -> {
                                if (err != null) {
                                    ToastBar.showErrorMessage(idioma.getMensaje78() + ": " + err.getMessage());
                                } else {
                                    inicio();
                                }
                            });
                        } else {
                            inicio();
                        }
To answer your questions:
It is for Android.
I would like to use the Dialog, but I imagine that it cannot be done since the call is asynchronous.
Reply all
Reply to author
Forward
0 new messages