Android pattern input in application

2019-04-15 05:28发布

I would like to know if there are other alternatives for mediocre EditText password input for Android. Is there an API, or Open Source code that can be integrated to my app that is similar to the Lock Screen pattern unlocking? Where maybe the Intent returns a hash, number, string, or whatever that represents the Pattern input from the user.

I was thinking of something like.

  1. My Code calls intent.
  2. A similar to Lockscreen Pattern thingy shows
  3. User inputs his pattern
  4. Intent returns something that represents that patter.
  5. I do away with the returned data.

Why do i want/need this? In my app, I need an input password from the user (Not to be used for logging in or something, used for encryption). And i thought it is tedious for the user to type. And it would be easier for those swipe lock patterns.

1条回答
时光不老,我们不散
2楼-- · 2019-04-15 06:08

Have a look at this project android-lockpattern It should do the trick.

For example, to create new pattern use

...
// this is your preferred flag
private static final int _ReqCreatePattern = 0;

...

Intent intent = new Intent(context, LockPatternActivity.class);
intent.putExtra(LockPatternActivity._Mode, LockPatternActivity.LPMode.CreatePattern);
startActivityForResult(intent, _ReqCreatePattern);

And then get the result

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case _ReqCreatePattern:
        if (resultCode == RESULT_OK) {
            String pattern = data.getStringExtra(LockPatternActivity._Pattern);
            ...
        }
        break;
    }
}
查看更多
登录 后发表回答