For the app I'm writing, if the user locks their phone while running the app I want a pin screen to pop up when the application resumes from the locked state. Is there a callback method or something that I can use to capture that state change?
Application Callback On Device Unlock
2k Views Asked by Eric At
2
There are 2 best solutions below
0

Create a broadcast receiver for ACTION_USER_PRESENT ....set a flag in your application preference when the onReceive() of the broadcast receiver is invoked...In the onResume() of your activity check for the flag...If flag is set(means the user has locked and unlocked the phone) show the PIN activity(do not forget to reset the flag in the preference).
You will need to extend BroadcastReceiver, which has a method called onReceive, which expects a context and an intent.
You can then ask the intent something like:
Cheers...