I am building an android application and one of the requirements is that the application needs to let the user define a passcode to lock the application so, once the passcode was set by the user, the passcode will be required to enter or re-enter the application.
Instead of passcode I am going to use this android library, https://code.google.com/p/android-lockpattern, that provides the same pattern behavior as the home lockscreen, using pattern.
So far, thats ok.
If the application is open on the first time, which mean, onCreated() is called, I can check if there is any passcode set and if yes, redirect the user to the screen where he/she needs to enter the pattern. If pattern valid, ok, user is in, if not, show an error and leave the application. This scenario is ok.
However, if the user hits the home button and re-enter the application, onCreated is not called, so now there wont be any passcode check. So I was looking at the other activity lifecycle's methods like onPause, onRestart, onResume, etc... all of them are called when the user re-enter the application, and ALSO, when the user navigates back to the Activity by pressing the back button.
So I am a bit confused/lost on where should this passcode check be besides the onCreated? I dont want to show the passcode screen when the user is navigating thru activities and suddenly returns back to the MainActivity.
How can I make sure the user will be required to enter its passcode either when starting the application or re-entering the application.
Thank you TL