WorkManger works on Oreo but not Lollipop

半城伤御伤魂 提交于 2019-12-11 00:23:42

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/50861872/workmanger-works-on-oreo-but-not-lollipop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!