DEV Community

Fayaz Bin Salam
Fayaz Bin Salam

Posted on

AndroidAppLockscreen: drop a PIN lockscreen into any Android app in minutes

most android apps that need any kind of auth go straight to biometrics or firebase. fine — but what if you just need a simple PIN lockscreen? no backend, no cloud calls, just "enter your code to continue".

that's what AndroidAppLockscreen does.

i built it after copy-pasting the same lockscreen implementation across three different projects. the design is inspired by Diary — clean, minimal, nothing fancy.

what it handles

  • set password
  • check password on launch
  • change password
  • disable password
  • forgot password flow
  • customisable background color

setup

add the JitPack repo and one dependency:

implementation 'com.github.p32929:AndroidAppLockscreen:1.2'
Enter fullscreen mode Exit fullscreen mode

extend your activities with LockscreenHandler, then in MainActivity's onCreate:

EasyLock.checkPassword(this);
Enter fullscreen mode Exit fullscreen mode

first launch, no password set → does nothing. password set → blocks app until correct code is entered.

managing passwords after that:

EasyLock.setPassword(activity);
EasyLock.changePassword(activity);
EasyLock.disablePassword(activity);
Enter fullscreen mode Exit fullscreen mode

the non-obvious part

the tricky bit wasn't the UI. it was activity lifecycle. you don't want the lockscreen triggering on screen rotation or when the user returns from a camera/file picker intent. LockscreenHandler handles all of that — it knows the difference between "user left the app" and "activity was recreated internally".

64 stars, 21 forks, MIT licensed.

repo: https://github.com/p32929/AndroidAppLockscreen

would love feedback, PRs, or stars if it saves you time. open to building with sharp teams and solo founders — dms open.

Top comments (0)