如何在Android设备中使用本机指纹扫描仪UI?

时间:2019-08-13 06:43:13

标签: android kotlin fingerprint android-fingerprint-api

要求:如何在屏幕传感器android设备(如Samsung s10 plus)上使用本机指纹扫描仪UI。

指纹认证的工作流程是可以理解的。但是,是否有任何方法或库可用于获取本机指纹扫描仪用户界面?

1 个答案:

答案 0 :(得分:1)

解决方案是创建一个自定义UI并替换它,以便所有设备都使用相同的UI

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