如何在android中以相同的时间间隔在后台运行多个服务? 。我尝试使用AlarmManager,但是在这种情况下它并没有像每隔5分钟一样以相同的间隔运行(有时它正常运行但不是所有时间都运行)。请建议我实现这一目标的最佳方法。提前谢谢。
答案 0 :(得分:-1)
To run the multiple services in particular interval, you can use timertask
Timer timer =new Timer();
TimerTask timerTask= new TimerTask() {
public void run() {
//TODO
}
};
timer.schedule(timerTask, 1000, 1000);
Example for Service,
public class ServcieSample extends Servcie{
public void onCreate(){
}
}
Inside onCreate you can create any number of threads or asynctask for background operations.