import java.util.Date; import java.util.Timer;
import java.util.TimerTask; public class ClassExecutingTask { long delay = 10*1000; // delay in ms : 10 * 1000 ms = 10 sec. LoopTask task = new LoopTask(); Timer timer = new Timer("TaskName"); public void start() { timer.cancel(); timer = new Timer("TaskName"); Date executionDate = new Date(); // no params = now timer.scheduleAtFixedRate(task, executionDate, delay); } private class LoopTask extends TimerTask { public void run() { System.out.println("This message will print every 10 seconds."); } } public static void main(String[] args) { ClassExecutingTask executingTask = new ClassExecutingTask(); executingTask.start(); } } On Thu, Jul 5, 2012 at 5:33 PM, Rahul Kaushik <rahulkaushi...@gmail.com>wrote: > Hi, > > Can anyone pls tell me the best way to call an method after every 5 min > (handler,timer),i googled and found handler.postdeleyd doesnt not guarntee > to execute,timer hangs some time ,pls suggest me the way to call method > after every 5 minutes > Code snippet will be very useful > > Thanks > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- WITH REGARDS ARUN KUMAR P D +91-9994794759 -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en