i have a method in my app that i want to be called repeatedly depending on what the user chooses. like if every hour is chosen by the user, the activity fires a method that is being called every hour. i would like to know the best way to schedule this repeated task.
i have been experimenting with Timers and Timer task, but for some reason it doesn't not seem to work when i use the java calendar class with it, like this:
Calendar c1 = Calendar.getInstance();
c1.add(Calendar.SECOND, 30);
updateTimer.scheduleAtFixedRate(cleanCompletedCache, c1.getTimeInMillis(),hour );
and from what i have been reading, Handlers are not suitable for this multi-repeating task. would i have to use an alarm manager for this and why won't the above code execute correctly? thanks