Android 6.0+指纹识别心得

Android 6.0+Fingerprint心得

我的demo链接
google官方demo
google相关API:android.support.v4.hardware.fingerprint

具体实现:实现某个功能模块我认为最有效的方法就是找到该功能模块的启动方法(看别人代码我认为很有效的方法),然后逆推看明白整个工作流程。千万不要盲目的从第一行代码慢慢的一行一行的看,这样效率会很低,也很乏味。步入正题,先找到Fingerprint的启动方法:

/*
Request authentication of a crypto object. This call  warms up the fingerprint hardware and starts scanning for a fingerprint. It terminates when onAuthenticationError(int, CharSequence) or {@link AuthenticationCallback#onAuthenticationSucceeded(AuthenticationResult) is called, at which point the object is no longer valid. The operation can be canceled by using the provided cancel object.
*/
public void authenticate (FingerprintManagerCompat.CryptoObject crypto, 
                int flags, 
                CancellationSignal cancel, 
                FingerprintManagerCompat.AuthenticationCallback callback, 
                Handler handler)

这个方法是FingerprintManagerCompat类的公有方法,然后想办法把这个方法需要的几个参数给他,最后在调用他,这个功能大体就实现了;嗯,中间当然还有一些细节需要注意,比如如何实例化那几个类,可不可以传null之类的。下面给出我demo的具体代码,大家挑重要的看,然后按我说的方法看(这个方法authenticate着手哦),试试效果。
AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.contacts.lhj.myfingerprinttest">

    <!--指纹权限-->
    <uses-permission android:name="android.permission.USE_FINGERPRINT" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <act
  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值