安卓sdk&计时器(计时器与线程)
使用 Android 堆栈调用计时器的内置方法很少, 一个很好的例子是 Chronometer。
我想集成使用 Thread.sleep() 方法实现计时器的代码段(线程),
我计划让一个服务调用该线程并与其通信。
与 Chronometer 相比,使用 sleep() 方法有什么缺点吗?
There are few built in ways to invoke a timer using the Android stack,
A good example is the Chronometer.
I would like to integrate piece of code (A thread)that implements timer using the Thread.sleep() method
I plan to have a Service tat invoke this thread and communicate with it.
Are there any disadvantages of using the sleep() method over Chronometer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于它是否对生命周期敏感。如果您的活动或服务将暂停,您的计时器将停止。查看闹钟管理器。该网站上有很多相关示例。
It depends if it's sensitive to lifecycle. If your activity or service will be paused your timer will be stopped. Look into Alarm Manager. There are plenty of examples on this site about.