开发者

saving activity state on close of the app by back key press

开发者 https://www.devze.com 2023-03-08 08:02 出处:网络
I am creating an App. It has 4 count-down timers. My problem is, In the middle of the count-down timer running user may press the back key and close the App. I want to let the countdown-timer run it\

I am creating an App. It has 4 count-down timers. My problem is, In the middle of the count-down timer running user may press the back key and close the App. I want to let the countdown-timer run it's count so that the user can see the updated version of it when he opens the App on next time. I thought to manage the state using onSaveInstanceState Callback but I read in the document that it been not called on the event of back key press of the activity. And I tried to check...yes it is not. Is any chance I can solve this using services?

Can someone shed开发者_如何学C some light on this please.

Note: I am using Handler.postDelayed for running count-down timers.

Thanks


If you want to catch the event when the user presses the back key, there's a method on the Activity class you can override, I believe it's onBackKeyPressed

0

精彩评论

暂无评论...
验证码 换一张
取 消