0

My requirement is when i minimize my app and maximize (open), one specific password enter screen must be display(Every time open when user open this app, and this is simple locale password). if user enter correct code then open the last activity where user left before minimize the app. And in my app there is lot of java class activity. in some solution stack overflow user suggest to use SharedPreferences for this. But i don't know how to apply that, so any idea?

Harin Kaklotar
  • 305
  • 7
  • 22
  • hee every time you want to open an password activity and after a write pass is entered you want to open a last closed activiy – santoXme Dec 23 '15 at 10:23
  • please show the code in `when you minimize my app and maximize (open), one specific password enter screen must be display` – Linh Dec 23 '15 at 10:24
  • 1
    this may be of some help: http://stackoverflow.com/questions/20969848/passcode-on-resume-from-background – Shahbaaz90 Dec 23 '15 at 10:24
  • @Shahbaaz90 thanks, is there any way without using SharedPreferences ? – Harin Kaklotar Dec 23 '15 at 10:35
  • @santoXme yes it should work like app locker is inbuilt with application – Harin Kaklotar Dec 23 '15 at 11:04
  • 1
    yup you can do it without shared preference you can use saved activity instance to save the last opening state of app....for every time open an lockscreen activity you canuse a life cycle of activity ...when a activity go in background and again come some method called use that methods .... – santoXme Dec 23 '15 at 11:08

1 Answers1

0

You can maintain a boolean value to check weather the onStart is called for the first time. So if the onStart method is called again you can know that the activity is just minimized and then reopened. You can show the password prompt on that time.

private boolean isOnStartCalledFirstTime = false;
@Override
protected void onStart() {
    super.onStart();
    if(!isOnStartCalledFirstTime){
        isOnStartCalledFirstTime = true;
    }else {
        //Show password prompt
    }
}
Sujith Niraikulathan
  • 2,111
  • 18
  • 21