在Android可靠重复的后台任务 [英] Reliable repeating background task on android

查看:187
本文介绍了在Android可靠重复的后台任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行它运行每分钟左右为一个Android应用程序后台的任务,但我在努力确保任务实际运行的每一分钟。我已经尝试了各种方法使用SystemClock.sleep()到AlarmManager(包括重复报警和固定报警),但似乎,除非该设备是充电任何重复的系统具有可变重复率,一旦该设备拔出。有没有什么办法来运行稳定持续重复的服务?

I'm trying to run a background task which runs every minute or so for an android application but I am struggling to ensure that the task actually runs every minute. I've tried a variety of approaches from using SystemClock.sleep() to the AlarmManager (both repeating alarm and a fixed alarm) but it seems that unless the device is charging any kind of repeating system has a variable repeat rate once the device is unplugged. Is there any way to run a stable consistently repeating service?

推荐答案

你有没有实施的定时器?它的工作原理非常好我用它,但话又说回来我并不担心precision的。据我所知,这可能会改变一下,但我对此表示怀疑。看来pretty的一致给我。

Have you implemented Timer? It works very well for what I use it for, but then again I haven't worried about the precision at all. For all I know it may be varying a bit but I doubt it. It seems pretty consistent to me.

编辑:我是你的责任或不负责任地使用这一设施不承担责任;)

I am not liable for your responsible or irresponsible use of this facility ;)

这篇关于在Android可靠重复的后台任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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