Short Version: WorkManager doesnt work on MIUI devices! (as stated in the title)
Detailed Version: I have been searching on this topic for days and I'm frustrated. In my app (which is working offline) I am supposed to send notification on certain hours of the day. However it seems like there is no proper way of doing this at all. The last approach I found was using the WorkManager which seemed to work fine on most devices (alarmmanager doesnt work at all when the app is killed after android O). But in Xiamo devices, the WorkManager doesn't work. Only if you manually allow some feature the WorkManager works (auto start and no restrictions for battery optimizatino) which is not a good solution as their location is different in different devices and is hard to find for normal users.
If you faced the same problem, can you tell me how to fix it? what is the point of WorkManager if doesn't work on background?!
P.S. : Workmanager works fine when the app is open. it also works fine on the emulator so there is no problem in the implementation.
Here is the code I used to send the request:
PeriodicWorkRequest workRequest =
new PeriodicWorkRequest.Builder(UploadWorker.class, 24 , TimeUnit.HOURS)
.setInitialDelay(1, TimeUnit.MINUTES)
.build();
WorkManager.getInstance(getContext())
.enqueueUniquePeriodicWork("FIRST_TIMER", ExistingPeriodicWorkPolicy.REPLACE,workRequest);