详细了解Android指纹识别和基本用法

电脑杂谈  发布时间:2020-06-11 05:01:04  来源:网络整理

安卓第一个指纹识别_华为电脑开机识别不了指纹_安卓英文识别

本文分享了Android指纹识别的理解和基本用法,供您参考. 具体内容如下

1. 实际上,已经有很多博客写指纹,但是在许多情况下,很多博客写得太多. 对于那些需要快速起步并运行的人安卓第一个指纹识别,没有耐心去看这么多的原理,源代码和类似的东西. 大多数人直接复制和修改.

华为电脑开机识别不了指纹_安卓英文识别_安卓第一个指纹识别

2. 房东说,一开始,他还直接查看了别人的密码,将它们一一删除,非常醉酒,下载演示文件也需要c. 因此,让我们自己记录一下. 每个人都可以方便地复制. 哈哈.

3. 首先看一下仿制支付宝的效果.

安卓第一个指纹识别_华为电脑开机识别不了指纹_安卓英文识别

4. 基本识别功能可以完成安卓第一个指纹识别,因为每个人的需求都不同,所以这只是一个演示,因为我的手机一次最多可以识别5次. 5次之后,您必须等待30秒钟左右才能重新识别.

5. 主代码,记住要添加权限.

安卓第一个指纹识别_华为电脑开机识别不了指纹_安卓英文识别

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

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentActivity;
import android.support.v4.hardware.fingerprint.FingerprintManagerCompat;
import android.view.View;
import android.view.animation.CycleInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
 
public class FingerActivity extends FragmentActivity {
 private Button mCancelBtn;
 private ImageView mShakeImage;
 private TextView mTryText;
 private int mCount=5;
 private FingerPrintUtils mFingerUtils;
 private TranslateAnimation mAnimation;
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_finger);
 
 mCancelBtn = (Button) findViewById(R.id.finger_cancel);
 mCancelBtn.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
  finish();
  }
 });
 mTryText= (TextView) findViewById(R.id.try_text);
 mTryText.setText("请轻触感应器验证指纹");
 mShakeImage = (ImageView) findViewById(R.id.image_finger);
 mAnimation=new TranslateAnimation(0,5,0,0);
 mAnimation.setDuration(800);
 mAnimation.setInterpolator(new CycleInterpolator(8));
 mFingerUtils=new FingerPrintUtils(this);
 mFingerUtils.setFingerPrintListener(new FingerCallBack());
 }
 
 
 private class FingerCallBack extends FingerprintManagerCompat.AuthenticationCallback{
 //多次识别失败,并且,不能短时间内调用指纹验证
 @Override
 public void onAuthenticationError(int errMsgId, CharSequence errString) {
  super.onAuthenticationError(errMsgId, errString);
  if (mCount>1){
  mCount--;
  mTryText.setText("指纹不匹配,还可以尝试"+mCount+"次");
  }else {
  mTryText.setText("1分钟后可重试!");
  }
  mHandler.sendMessageDelayed(new Message(), 1000 * 60);
 }
 
 //出错可恢复
 @Override
 public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
  super.onAuthenticationHelp(helpMsgId, helpString);
 }
 
 //识别成功
 @Override
 public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationResult result) {
  super.onAuthenticationSucceeded(result);
  mFingerUtils.stopsFingerPrintListener();
  finish();
  Toast.makeText(FingerActivity.this, "识别成功+++", Toast.LENGTH_SHORT).show();
 
 }
 
 //识别失败
 @Override
 public void onAuthenticationFailed() {
  super.onAuthenticationFailed();
  if (mCount>1){
  mCount--;
  mTryText.setText("指纹不匹配,还可以尝试"+mCount+"次");
  }
  mShakeImage.startAnimation(mAnimation);
 }
 }
 
 private Handler mHandler=new Handler(){
 @Override
 public void handleMessage(Message msg) {
  super.handleMessage(msg);
  if (mFingerUtils!=null){
  mFingerUtils.reSetFingerPrintListener(new FingerCallBack());
  }
  mCount=5;
  if (mTryText!=null) {
  mTryText.setText("请轻触感应器验证指纹");
  }
 
 }
 };
 
}

华为电脑开机识别不了指纹_安卓英文识别_安卓第一个指纹识别

6. 问题与解决方案

FingerPrintManagerCompat,这是一个兼容的FingerPrint操作类,并且有一个类似的名为FingerPrintManagerCompatApi23的类. 使用这两类也可以实现指纹识别的功能,但是也有不足之处. 这两个类都可以达到这种效果,但是版本必须为23或更高. 如果无法实现,将不会报告错误,因为它不会这样做,我相信每个人也会做出判断.

某些型号可能不兼容,毕竟制造商太多. 我没有太多要测试的机器.

7. 每个人都可以下载的演示地址.

github: fingerIdentify


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/shouji/article-241408-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...