androidkotlinfingerprintandroid-fingerprint-api

How to use native fingerprint scanner UI in android devices?


Requirement : How to use native fingerprint scanner UI for onscreen sensor android devices (like Samsung s10 plus).

Working flow of fingerprint authentication is understandable. But is there any method or libraries available for obtaining native fingerprint scanner UI ?


Solution

  • Solution is to create a custom UI and replace it so that it'll be same UI for all devices

    public class MyFingerPrintDialog extends BottomSheetDialog implements 
    View.OnClickListener {
    
    private Context context;
    
    private Button btnCancel;
    private TextView itemTitle;
    
    private BiometricCallback biometricCallback;
    
    public MyFingerPrintDialog(@NonNull Context context) {
        super(context, R.style.BottomSheetDialogTheme);
        this.context = context.getApplicationContext();
        setDialogView();
    }
    
    public MyFingerPrintDialog(@NonNull Context context, BiometricCallback biometricCallback) {
        super(context, R.style.BottomSheetDialogTheme);
        this.context = context.getApplicationContext();
        this.biometricCallback = biometricCallback;
        setDialogView();
    }
    
    public MyFingerPrintDialog(@NonNull Context context, int theme) {
        super(context, theme);
    }
    
    protected MyFingerPrintDialog(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }
    
    private void setDialogView() {
        View bottomSheetView = getLayoutInflater().inflate(R.layout.view_bottom_sheet, null);
        setContentView(bottomSheetView);
    
        btnCancel = findViewById(R.id.btn_cancel);
        btnCancel.setOnClickListener(this);
    
        itemTitle = findViewById(R.id.item_title);
    }
    

    BiometricCallback

    public interface BiometricCallback {
    
    void onAuthenticationFailed();
    
    void onAuthenticationCancelled();
    
    void onAuthenticationSuccessful();
    }