什么是指纹识别
早在1684年,英国植物形态学家Grew便发表了第一篇研究指纹的科学论文,到20世纪90年代,用于个人身份鉴定的自动指纹识别系统得到开发和应用,而Android从6.0系统开始就支持指纹解锁功能,指纹解锁带给我们的便利不言而喻,现在更是有屏幕指纹解锁、人脸解锁等各种技术给我们的生活带来了极大的便利,下面是指纹解锁的一个简单实现。
具体实现
首先创建一个Empty Activity项目,我的项目名是FingerPrintDemo,在布局页面activity_main.xml中加入以下代码
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_fingerprint"
/>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入指纹"
android:textSize="18sp" />
<Button
android:id="@+id/btn_activity_main_finger"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView"
android:layout_marginTop="20dp"
android:text=