I want to run a specific method doThis()
(which is not a CPU intensive action, it's just a POST to a web server) every 10 minutes and when that method is finished executing, to notify the user (via Toast
or Notification
or something of the sort). But I don't want to block up the UI thread because I expect the user to still be interacting with the UI. What is the most efficient way to do this? Through a Handler
? Or a Service
or some sort (i.e. IntentService
)?
The most clean and efficient way IMO is to use ScheduledThreadPoolExecutor, check out my answer here for the code example, hope this help.