I have a scenario where i have to give user notification using WorkManager at specific time.
How can i schedule Work at specific time, and it should show up even if user force kills the app. or app is not running.
My Current code is as below :
Data d = new Data.Builder().putInt(IntentConstants.SCHEDULE_ID, scheduleData.getScheduleID()).build();
OneTimeWorkRequest compressionWork =
new OneTimeWorkRequest.Builder(ScheduleWorker.class)
.setInputData(d)
.build();
WorkManager.getInstance().enqueue(compressionWork);
WorkManager
work at an exact time. But you can make sure you are white-listed by using a high-priority FCM, and enqueue (and run) the work then. Another option is theAlarmManager
setExactAndAllowWhileIdle()
method. Look here (Doze and App Standby section) - google-developer-training.gitbooks.io/… – Wappes