DevStore首页 > DEV资源 > 源码下载 > 源码详情

Android studio指纹识别demo

 
erpei | 2017-03-25 14:33    浏览量(2144)    评论(3)    收藏(5)
功能分类:工具 支持平台:Android 运行环境:Android
开发语言:Java 开发工具:Android Studio 源码大小:257.40KB
下载源码 228 人下载

源码简介

添加库,在app登录界面使用指纹识别模块实现指纹登陆

源码截图

  • 启动服务
  • 识别错误
  • 识别成功
DevStore所有源码来自用户上传分享,版权问题及牵扯到商业纠纷均与DevStore无关。

源码片段

public class MainActivity extends AppCompatActivity {

    private FingerPrinterView fingerPrinterView;
    private int fingerErrorNum = 0; // 指纹错误次数
    RxFingerPrinter rxfingerPrinter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        fingerPrinterView = (FingerPrinterView) findViewById(R.id.fpv);
        fingerPrinterView.setOnStateChangedListener(new FingerPrinterView.OnStateChangedListener() {
            @Override public void onChange(int state) {
                if (state == FingerPrinterView.STATE_CORRECT_PWD) {
                    fingerErrorNum = 0;
                    Toast.makeText(MainActivity.this, "指纹识别成功", Toast.LENGTH_SHORT).show();
                }
                if (state == FingerPrinterView.STATE_WRONG_PWD) {
                    Toast.makeText(MainActivity.this, "指纹识别失败,还剩" + (5-fingerErrorNum) + "次机会",
                            Toast.LENGTH_SHORT).show();
                    fingerPrinterView.setState(FingerPrinterView.STATE_NO_SCANING);
                }
            }
        });
        rxfingerPrinter = new RxFingerPrinter(this);
        findViewById(R.id.btn_open).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fingerErrorNum = 0;
                rxfingerPrinter.unSubscribe(this);
                Subscription subscription = rxfingerPrinter.begin().subscribe(new Subscriber() {
                    @Override
                    public void onStart() {
                        super.onStart();
                        if (fingerPrinterView.getState() == FingerPrinterView.STATE_SCANING) {
                            return;
                        } else if (fingerPrinterView.getState() == FingerPrinterView.STATE_CORRECT_PWD
                                || fingerPrinterView.getState() == FingerPrinterView.STATE_WRONG_PWD) {
                            fingerPrinterView.setState(FingerPrinterView.STATE_NO_SCANING);
                        } else {
                            fingerPrinterView.setState(FingerPrinterView.STATE_SCANING);
                        }
                    }

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        if(e instanceof FPerException){
                            Toast.makeText(MainActivity.this,((FPerException) e).getDisplayMessage(),Toast.LENGTH_SHORT).show();
                        }
                    }

                    @Override
                    public void onNext(Boolean aBoolean) {
                        if(aBoolean){
                            fingerPrinterView.setState(FingerPrinterView.STATE_CORRECT_PWD);
                        }else{
                            fingerErrorNum++;
                            fingerPrinterView.setState(FingerPrinterView.STATE_WRONG_PWD);
                        }
                    }
                });
                rxfingerPrinter.addSubscription(this,subscription);
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        rxfingerPrinter.unSubscribe(this);
    }
}
  •   赞(0) 赞 +1 赞(0) 已赞
  •   收藏(5) 收藏 +1 已收藏 取消
  •   下载(228)
评论(3)
二马小迪

二马小迪 2017-07-26 17:07:41

学习学习!
回复(0) 赞(0) 赞(1)
xiaozhisoft

xiaozhisoft 2017-07-07 11:50:15

下载下来试试看
回复(0) 赞(0) 赞(1)
超世纪

超世纪 2017-05-19 08:42:17

为什么我的运行不了
回复(0) 赞(0) 赞(1)
  • 推荐
  • 审核
  • 收录
  • 获取活力值

源码上传作者

  • 0 能力值
  • 1 源码
  • 0 评测
  • 0 资料