运行任务每隔几个小时 [英] Running a task every few hours

查看:127
本文介绍了运行任务每隔几个小时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我需要运行每隔几个小时,即使用户没有重新打开应用程序的方法。
什么是最好的方式去?
我应该使用Timer类或报警经理吗?
谢谢!

I have a method that I need to run every few hours even if the user didn't reopen the app. What is the best way to go? Should I use the Timer class or Alarm manager? Thanks!

推荐答案

您应该使用此AlarmManager 调度服务。看到这个 Vogella教程

You should use AlarmManager to schedule services for this. See this Vogella tutorial.

这篇关于运行任务每隔几个小时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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