是否CountDownTimer工作,如果我关闭应用程序? [英] Does CountDownTimer work if I close the app?

查看:235
本文介绍了是否CountDownTimer工作,如果我关闭应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 CountDownTimer 来发送消息。我不知道这是否工作,如果我关闭应用程序?

下面是我的code:

 新CountDownTimer(WAITTIME * 1000,1000){
    公共无效onTick(长millisUntilFinished){}
    公共无效onFinish(){forSend(); }
}。开始();


解决方案

请记住,当你接近一个应用程序是没有必要的一个死的应用程序,当dissapear从屏幕上完全就进入停止状态的应用程序(调用的onPause(),然后的onStop()),那么它需要一定的时间来调用onFinish(),之后该应用从直接调用onStart(),而不再次使的onCreate()被称为一个reacheable应用不再存在,因此,如据计时器仍在计算你的应用程序将是活着等待计数器结束,(从annonymous CountDownTimer对象onFinish())致电onFinish的forSend()()和应用程序做的最后一件事是onFinish ()从活动课,当然,即使你覆盖与否。

I use the CountDownTimer to send a message. I wonder does this work if I close the app?

Here is my code:

new CountDownTimer(waitTime*1000, 1000) {
    public void onTick(long millisUntilFinished) {}
    public void onFinish() { forSend(); }
}.start();

解决方案

Remember that when you "close" an app is not necessary a "dead" app, when an app dissapear completely from the screen it goes to Stop state (calling onPause() and then onStop()) , then it take some time to call onFinish(), after that the app no longer exist as a reacheable app from directly onStart() to be called without making the onCreate() again, so as far as the timer still counting your app will be "alive" waiting for the counter to end and call the forSend() at onFinish() (the onFinish() from your annonymous CountDownTimer object) and the last thing the app do is the onFinish() from Activity Class of course, even if you overwrite it or not.

这篇关于是否CountDownTimer工作,如果我关闭应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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