Skip to content
CrossFly is 100% open sourceFollow us on GitHub
CrossFlyCrossFly
Get started

This page was machine-translated from Portuguese and may contain errors. The Portuguese version is canonical.

Biometrics

Fingerprint/face authentication in a portable way, with Biometry. The result arrives asynchronously via callback — dispatch it to the UI with onUI(...).

Usage

if (!Biometry.isAvailable()) {
   loginPorSenha();               // fallback when there is no biometrics
   return;
}
Biometry.authenticate(
   "Confirme sua identidade",     // reason (shown to the user)
   "Cancelar",                    // text of the cancel button
   false,                         // onlyBiometric: false = allows the system PIN as a fallback
   (resultado, mensagem) -> Component.onUI(() -> {
      switch (resultado) {
         case SUCCESS:   abrirAreaSegura(); break;
         case FAILURE:   Hint.show("Não reconhecido", 2000); break;
         case CANCELLED: /* user gave up */ break;
         case ERROR:     Hint.show("Erro: " + mensagem, 2000); loginPorSenha(); break;
      }
   })
);

API

Member Signature
Biometry.isAvailable() static boolean — is there hardware/enrolled biometrics?
Biometry.authenticate(...) static void (String reason, String cancel, boolean onlyBiometric, Callback)
Callback.onResult(...) (AuthResult result, String message)
AuthResult SUCCESS · FAILURE · CANCELLED · ERROR
  • onlyBiometric = true requires biometrics (no falling back to the system PIN/password); false allows the OS fallback.

Security

  • Biometric data never leaves the device — the app only receives SUCCESS/FAILURE/etc., never the fingerprint/face itself.
  • Always offer an application fallback (login/password) for ERROR and for when isAvailable() is false.

Common mistakes

  • Handling only SUCCESS and ignoring CANCELLED/ERROR (the user gets stuck).
  • Touching the UI directly in the callback — it comes off the paint thread; use onUI(...).
  • Not having an alternative path when there is no biometrics.

See also

Was this page helpful?