简体   繁体   中英

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 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();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM