ScheduledThreadPoolExecutor for a periodic task (using Retrofit) just firing once and never again ScheduledThreadPoolExecutor for a periodic task (using Retrofit) just firing once and never again multithreading multithreading

ScheduledThreadPoolExecutor for a periodic task (using Retrofit) just firing once and never again


There may be some exception will be occuring because of which subsequent calls will be suppressed. ScheduledThreadPoolExecutor only "ticking" once

So try to put your code inside runnable of runOnUiThread like Scheduling recurring task in Android


I am currently developing similar things in android. See if this helps you:

ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);executor.scheduleAtFixedRate(getReloadTask(position), 0, 20, TimeUnit.SECONDS);