Search code examples
javaandroidandroid-architecture-componentsandroid-workmanager

WorkManger works on Oreo but not Lollipop


WorkManager states that it works on OSes before JobScheduler and the like, yet it doesn't seem to work on API levels that use AlarmManager. I have a PeriodicWorkRequest which runs in intervals just fine on Oreo, but on Lollipop, it only runs the first time.

The code in question (PeriodicWorker.class is my own class of course):

WorkManager
                    .getInstance()
                    .enqueue(
                            new PeriodicWorkRequest.Builder(
                                    PeriodicWorker.class,
                                    PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS,
                                    TimeUnit.MILLISECONDS
                            )
                                    .setConstraints(
                                            new Constraints.Builder()
                                                    .setRequiredNetworkType(NetworkType.CONNECTED)
                                                    .build()
                                    )
                                    .build()
                    );

My WorkManager dependency is android.arch.work:work-runtime:1.0.0-alpha03.

Here's a demo project: https://gitlab.com/neelkamath/work-manager-demo


Solution

  • Lollipop's functionality has been fixed in the newer version: android.arch.work:work-runtime:1.0.0-alpha04.