9宫格解锁 android_Android实现九宫格手势解锁

本文详细介绍了如何在Android应用中实现九宫格手势解锁功能,包括设置模式、错误次数限制、密码长度等关键步骤,并提供了相关代码示例。在验证和修改手势密码时需要注意旧密码的设置和管理。
摘要由CSDN通过智能技术生成

本文为大家分享了Android九宫格手势解锁的具体代码,供大家参考,具体内容如下

里面有关于这个东西的介绍和接入方式,这里就不累赘了,我只是说下里面没有的。

关于这个库的使用:

protected void initViews() {

//设置模式

LockMode lockMode = (LockMode) getIntent().getSerializableExtra(Config.INTENT_SECONDACTIVITY_KEY);

//是否显示手势的方向箭头

lv_lock.setShow(false);

//允许输入错误的次数

lv_lock.setErrorNumber(Config.GESTURE_ERROR_COUNT);

//设置手势密码的最小长度

lv_lock.setPasswordMinLength(Config.GESTURE_LENGTH);

//密码设置后立即保存在本地

lv_lock.setSavePin(true);

//设置保存在本地的手势密码的键

lv_lock.setSaveLockKey(Config.ZHCS_GESTURE_PWD_KEY);

//设置密码:LockMode.SETTING_PASSWORD

//修改密码:LockMode.EDIT_PASSWORD

//验证密码:LockMode.VERIFY_PASSWORD

//清除密码:LockMode.CLEAR_PASSWORD

switch (lockMode)

{

case CLEAR_PASSWORD:

lable = "清除密码";

break;

case EDIT_PASSWORD:

lable = "修改密码";

setOldPassword();

break;

case SETTING_PASSWORD:

lable = "设置密码";

break;

case VERIFY_PASSWORD:

lable = "验证密码";

//设置旧密码

setOldPassword();

break;

}

lv_lock.setMode(lockMode);

//设置密码输入接口回调

lv_lock.setOnCompleteListener(onCompleteListener);

}

/**

* s设置旧密码

*/

private void setOldPassword() {

String oldPwd = ConfigUtil.getInstance(this).getString(Config.ZHCS_GESTURE_PWD_KEY);

lv_lock.setOldPassword(oldPwd);

}

CustomLockView.OnCompleteListener onCompleteListener = new CustomLockView.OnCompleteListener() {

@Override

public void onComplete(String password, int[] indexs) {

ToastUtil.showShortToast(lable+"成功");

//finish();

}

@Override

public void onError(String errorTimes) {

ToastUtil.showShortToast("密码错误,还可以输入" + errorTimes + "次");

}

@Override

public void onPasswordIsShort(int passwordMinLength) {

ToastUtil.showShortToast("密码不能少于" + passwordMinLength + "个点");

}

@Override

public void onAginInputPassword(LockMode mode, String password, int[] indexs) {

ToastUtil.showShortToast("请再次输入密码");

}

@Override

public void onInputNewPassword() {

ToastUtil.showShortToast("请输入新密码");

}

@Override

public void onEnteredPasswordsDiffer() {

ToastUtil.showShortToast("两次输入的密码不一致");

}

@Override

public void onErrorNumberMany() {

ToastUtil.showShortToast("密码错误次数超过限制,不能再输入");

}

};

值得注意的是,在验证手势密码和修改手势密码的时候需要用到旧密码,而这个旧密码我断点带源码里面去发现是空的,并没主动去获取,需要我们手动设置,就是用到ConfigUtil这个类。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
The topic of this book is Reinforcement Learning—which is a subfield of Machine Learning—focusing on the general and challenging problem of learning optimal behavior in complex environment. The learning process is driven only by reward value and observations obtained from the environment. This model is very general and can be applied to many practical situations from playing games to optimizing complex manufacture processes. Due to flexibility and generality, the field of Reinforcement Learning is developing very quickly and attracts lots of attention both from researchers trying to improve existing or create new methods, as well as from practitioners interested in solving their problems in the most efficient way. This book was written as an attempt to fill the obvious lack of practical and structured information about Reinforcement Learning methods and approaches. On one hand, there are lots of research activity all around the world, new research papers are being published almost every day, and a large portion of Deep Learning conferences such as NIPS or ICLR is dedicated to RL methods. There are several large research groups focusing on RL methods application in Robotics, Medicine, multi-agent systems, and others. The information about the recent research is widely available, but is too specialized and abstract to be understandable without serious efforts. Even worse is the situation with the practical aspect of RL application, as it is not always obvious how to make a step from the abstract method described in the mathematical-heavy form in a research paper to a working implementation solving actual problem. This makes it hard for somebody interested in the field to get an intuitive understanding of methods and ideas behind papers and conference talks. There are some very good blog posts about various RL aspects illustrated with working examples,
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值