我正在尝试使用锁定模式库在我的应用程序中实现一些安全性
我已经按照这里的每一步https://code.google.com/p/android-lockpattern/wiki/QuickUse
并且由于某种原因我的代码[下面]触发了LockPatternActivity.RESULT_FAILED
所有LockPatternActivity
意图都正常运行
public void buttonClick() {
_prefs = getPreferences(MODE_PRIVATE);
String restoredText = _prefs.getString("pattern", null);
if(restoredText== null)
{
Intent intent = new Intent(LockPatternActivity.ACTION_CREATE_PATTERN, null, this, LockPatternActivity.class);
startActivityForResult(intent, REQ_CREATE_PATTERN);
}
else
{
char[] savedPattern = restoredText.toCharArray();
Intent intent = new Intent(LockPatternActivity.ACTION_COMPARE_PATTERN, null,
this, LockPatternActivity.class);
intent.putExtra(LockPatternActivity.EXTRA_PATTERN, savedPattern);
startActivityForResult(intent, REQ_ENTER_PATTERN);
}
}
@Override
protected void onActivityResult(int request, int result, Intent data) {
char[] pattern = data.getCharArrayExtra(LockPatternActivity.EXTRA_PATTERN);
if (request == REQ_CREATE_PATTERN) {
if (result == RESULT_OK) {
editor.putString("pattern", pattern.toString());
editor.apply();
}
} else if (request == REQ_ENTER_PATTERN) {
switch (result) {
case RESULT_OK:
break;
case RESULT_CANCELED:
// The user cancelled the task
break;
case LockPatternActivity.RESULT_FAILED:
// The user failed to enter the pattern
break;
case LockPatternActivity.RESULT_FORGOT_PATTERN:
// The user forgot the pattern and invoked your recovery Activity.
break;
}
}
}