Multiple services with the same time interval in android

How can I start multiple services in the background with the same time interval in android ?, I tried with AlarmManager but in this one it doesn't work at the same intervals as every 5 minutes (sometimes it works correctly but not all the time). Please suggest me the best way to achieve this. Thanks in advance.

+3


source to share


1 answer


    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.

      



-1


source







All Articles