Android 倒计时后退按钮与 Home 的比较

发布于 2024-09-06 19:25:25 字数 241 浏览 2 评论 0原文

我正在使用 .postdelayed() 编写一个倒计时器,当计时器减到零时,它每秒都会说话。我无法理解用户点击后退或主页按钮的后果。 按任一按钮时倒计时继续。当按下主页并重新单击该应用程序时,它会返回到相同的计数(这是我一直想要的)并继续倒计时。当您按后退键然后重新单击该应用程序时,您会得到一个尚未启动的新时钟,但我仍然在这里听到原始计时器的声音。我如何编写一个应用程序,使其只能有一个实例,并且如果应用程序正在运行,则选中该应用程序图标将始终转到活动版本?

I am writing a count down timer, using .postdelayed(), that speaks each second as the timer goes down to zero. I have trouble 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲鸠 2024-09-13 19:25:25

看看这个问题......它基本上是什么你需要。现在...如果您想知道这种行为,那只是当您按下 Home 按钮 时,您的应用程序不会被销毁,而是会暂停。但是,当您按下后退按钮时,当前活动将从堆栈中推送,这意味着您的应用程序被销毁(因此您最好保存应用程序的状态)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文