Android中哪种类型的服务会占用更多的系统资源
拥有一个持续运行计时器并每五秒执行一项任务的服务会更好吗?或者让警报管理器每五秒启动一次服务会更有效吗?每一秒又如何?我很想听听你的回应。谢谢!
Would it be better to have a service that is continually running a timer and executing a task every five seconds. Or would it be more efficient to have an alarm manager starting the service every five seconds? How about every second? I'm interested to hear your responses. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 AlarmManager 文档,它仅适用于您想要运行的情况在特定时间。对于您所讨论的内容,您将需要使用带有 postDelayed() 的处理程序。
According to the AlarmManager documentation, it's only for cases where you want to run at a specific time. For what you're talking about, you'll want to use a Handler, with postDelayed().