Issues with long running Handlers, Timers, and Tasks?

95 views Asked by At

I've seen a number of questions using the Handler or Timer implementations in Android apps to delay an update to the UI thread. Most of these seem to be short - a few seconds at most.

Are there issues with using a 24 hour delay for a task? How does Android handle very long running Hander and Timers?

1

There are 1 answers

0
CommonsWare On BEST ANSWER

Are there issues with using a 24 hour delay for a task?

It won't work reliably.

A Handler, or any other in-process timing option (e.g., ScheduledExecutorService) is only as good as the process that is hosting it. Once the process goes away, so does the timing. Android processes normally do not live for 24 hours.

If it makes you feel any better, all the other alternatives (e.g., AlarmManager, JobScheduler) will also not work reliably as of Android M, in the interests of power management. However, the alternatives will be efficiently unreliable, since they do not require your process to be constantly running.