0

我正在开发一个 android 应用程序,我在其中保存了锁定模式。当用户在打开屏幕电源时输入模式时,我正在检查它是否与保存的模式相同。

我正在使用以下方法在应用程序中保存模式:https ://github.com/haibison/android-lockpattern/

问题是两者的格式不同:

1) lockpattern 屏幕上电时捕获的对象:

[(row=1,clmn=0), (row=0,clmn=1), (row=1,clmn=1), (row=2,clmn=1), (row=1,clmn=2)]

2)我正在使用haibison的方法捕获这个:

char[] pattern = data.getCharArrayExtra(LockPatternActivity.EXTRA_PATTERN);
String lockpattern = new String(pattern);

您能否提供一些示例/链接。

我不应该使用haibison的方法吗?

4

1 回答 1

0

您必须在启动 Lockpattern-Intent 之前设置一个 Encrypter 以便从 haibison 的 char-array 中获得正确的表示,例如 LPEncrypter ( https://bitbucket.org/haibison/android-lockpattern/wiki/Encryption ):

AlpSettings.Security.setEncrypterClass(context, LPEncrypter.class);

例如,这种模式的简单表示:

简单模式

没有加密器的 Habisons char 数组是这样的:

[3,9,7,7,c,9,3,7,e,c,e,a,5,6,2,4,0,e,a,7,3,9,3,4,b,8,e,9,a,c,9,7,6,6,e,8,e,8,d,0]

使用带有 String[] ids = new String(pattern).split("[^0-9]") 的示例加密器;

你会得到[1,-,2,-,3,-,6]应该很容易转换成你的锁模式表示。

于 2016-01-08T11:02:09.347 回答