的onPause()或的onStop() [英] onPause() or onStop()

查看:137
本文介绍了的onPause()或的onStop()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不工作我预期的方式。不过,我希望它的工作方式是可能是错误的。

This isn't working the way I expected. However, the way I expect it to work is probably wrong.

我有一个实现倒数计时器的应用程序。当点击android手机上的后退按钮用户导航回到主屏幕。然而,倒数计时器仍然在后台运行。我可以告诉大家,因为它执行以一定的间隔啤酒。

I have an application that implements a Countdown timer. When the back button on the android phone is clicked the user is navigated back to the main screen. However, the countdown timer still runs in the background. I can tell as it performs a beer at certain intervals.

我想如果我实施的onPause()我就能够调用 countdowntimer.cancel()。而当用户退出通过后退按钮的行为,将取消倒计数计时器。但是,应用程序,而不是失败。

I thought if I implemented onPause() I would be able to call countdowntimer.cancel(). And it would cancel the count down timer when the user exits the activity via the back button. However, the application fails instead.

我也试图与的onStop了类似的方法(),但它只是不工作。

I have also tried a similar approach with onStop() but it just doesn't work.

我没有我的code。与我的那一刻,它只是在我的脑海。也对不起,如果有对这个职位的任何错误,我写的是我的手机上。

I don't have my code with me at the moment, it's just on my mind. Also sorry if there are any mistakes on this post, I have written it on my phone.

推荐答案

的onPause()拨打时的一个活动的控制转移到的另一个活动的,和的onStop()方法调用时的活动的在完成模式。

onPause() call when one Activity transfer control to another Activity, and onStop() method call when Activity in finish mode.

这篇关于的onPause()或的onStop()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆