How can I tell if my Application is resumed from background?

前端 未结 5 2018
北恋
北恋 2021-02-04 10:57

I want to lock my application when it goes in background and when it resumes I want to display my own lock screen. The lock screen is an Activity of my application.

Aft

5条回答
  •  耶瑟儿~
    2021-02-04 11:42

    Well you should override methods onResume and onPause

    see this and you will get it :)

    in your activity you can have a flag like boolean locked;

    and in onPause you can set this to true. And every time in critical places you can check the state of this flag and if it is true then you show you unlock activity, after a success in unlocking then set the flag to false.

提交回复
热议问题