android指纹解锁_Android指纹锁

android指纹解锁In this tutorial, we’ll be discussing the Android Fingerprint API and implement a Fingerprint Dialog in our android application. 在本教程中,我们将讨论Android Fingerprint API,并在android应用程序中实现Fingerpri...
摘要由CSDN通过智能技术生成

android指纹解锁

In this tutorial, we’ll be discussing the Android Fingerprint API and implement a Fingerprint Dialog in our android application.

在本教程中,我们将讨论Android Fingerprint API,并在android应用程序中实现Fingerprint Dialog。

Android指纹管理器 (Android Fingerprint Manager)

Fingerprint Manager is the class used to access the Fingerprint hardware from the device (if it exists).

指纹管理器是用于从设备(如果存在)访问指纹硬件的类。

Google recommends authenticating fingerprint in applications by displaying a DialogFragment with a Fingerprint icon to the user.

Google建议通过向用户显示带有指纹图标的DialogFragment来对应用程序中的指纹进行身份验证。

In order to implement Fingerprint Authentication, you need to add the following permission in the AndroidManifest.xml file:

为了实现指纹认证,您需要在AndroidManifest.xml文件中添加以下权限

<uses-permission android:name="android.permission.USE_FINGERPRINT" />

Following are the steps to implement Fingerprint Authentication in your application:

以下是在您的应用程序中实现指纹认证的步骤:

  • Check whether there is a secure lock on the lock screen

    检查锁屏上是否有安全锁
  • Check whether the Fingerprint Hardware is available using the FingerprintManager class.

    使用FingerprintManager类检查指纹硬件是否可用。
  • Check whether the user has enrolled at least one fingerprint.

    检查用户是否注册了至少一个指纹。
  • Get access to Android keystore to store a key used to initiate a Cipher.

    获取对Android密钥库的访问权限,以存储用于启动密码的密钥。
  • Start the Authentication Method and add the callback methods

    启动身份验证方法并添加回调方法

The Android Keystore system lets you store cryptographic keys in a container to make it more difficult to extract from the device.

Android Keystore系统可让您将加密密钥存储在容器中,以使其更难从设备中提取。

项目结构 (Project Structure)

(Code)

The code for the activity_main.xml layout is given below:

下面给出了activity_main.xml布局的代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="https://schemas.android.com/apk/res/android"
    xmlns:app="https://schemas.android.com/apk/res-auto"
    xmlns:tools="https://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="START AUTHENTICATION"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


</android.support.constraint.ConstraintLayout>

The code for the dialog_fingerprint.xml is given below:

下面给出了dialog_fingerprint.xml的代码:

<?xml version="1.0" e
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值