开发者

a count down android timer back button vs home

I am writing a count down timer, using .postdelayed(), that speaks each second as the timer goes down to zero. I have tr开发者_运维问答ouble understanding the consequences of the user hitting the back or home button. The countdown continues when hitting either button. When home is pressed and you reclick the app, it goes back to the same count(this is what i always want) and continues to count down. When you hit the back key and then reclick the app, you get a new clock that has not started but I still here the sounds from the original timer. How can I code an app so it only can have one instance and chicking the app icon will always go to the active version if it is running?


Take a look of this Question... it's basically what you need. Now... if you wonder about this behaivor it's just that when you press the Home Button your application is not destroyed but paused. But, when you press the Back Button, the current activity is pushed from the stack, and that means your application is destroyed (so you better save the state of your application).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜