I am enqueuing a PeriodicWorkRequest
through WorkManager
, the code mentioned below is working on device having Android OS Nougat also on emulators of Android OS versions 8.1, 9 & 10 but not on OnePlus (Android 9), Redmi 5 (Android 8.1) & Google Pixel (Android 9.1).
The dependency I have incorporated is,
implementation "android.arch.work:work-runtime:1.0.1" (Non Androidx)
Also
implementation "android.arch.work:work-runtime:2.1.0-beta02" (Androidx)
Code snippet,
PeriodicWorkRequest.Builder builder = new PeriodicWorkRequest.Builder(MyWorker.class,
PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS, TimeUnit.MILLISECONDS)
.addTag(Utils.TAG_WORKER)
.setInputData(createInputData(config));
WorkManager.getInstance(Context).enqueueUniquePeriodicWork(Utils.TAG_WORKER, ExistingPeriodicWorkPolicy.KEEP, builder.build());
private Data createInputData(Config config) {
return new Data.Builder()
.putString(Utils.USER_CONFIG, new Gson().toJson(config))
.putString(Utils.LOCATION_CONFIG, new Gson().toJson(Preferences.getInstance(fragmentActivity).getConfiguration()))
.build();
}
I have tried and searched a lot, any help regarding will be much appreciated.
Sample Implementation: https://db.tt/gFEJi39Ofz
Google Issue Tracker link: https://issuetracker.google.com/issues/135865377