Scheduling tasks to run at regular intervals

I'd like to run a background task once every hour or so. I know how to fire a background task through the Application class, but I can't figure out how I can schedule a task to run at regular intervals. Is this possible / allowed?

 

0
3 comments
Official comment

You can use AppExecutorUtil.getAppScheduledExecutorService().scheduleWithFixedDelay and do whatever you like inside.

Avatar
Permanently deleted user

Thanks, that is exactly what I've been looking for. Is this covered by documentation? I've been going through the docs quite a while and feel stupid if it is ;)

0

Yes, scheduleWithFixedDelay is a JDK method and so it's covered by JDK documentation. getAppScheduledExecutorService is just an instance of a ScheduledExecutorService with some special properties (also described in the javadoc), but you could create/use any other executor as well.

0

Please sign in to leave a comment.