I am building a functionality that will allow merchants to set the schedule of their business. Such functionality would automatically change the variable open to true and false accordingly to the times the merchant set in each day of the week. Therefore, there would be a total of 14 possible different times.
I am trying to build a recurrent background task that would accomplish such a thing using WorkManager, the new Android Architecture Components library.
val scheduleStartWork = PeriodicWorkRequest.Builder(ScheduleWorker::class.java, 7, TimeUnit.DAYS)
.setInputData(Data.Builder().putBoolean("isStart", true).build())
.setScheduleRequestedAt(diff_time, TimeUnit.MILLISECONDS)
.addTag(weekdays[index])
.build()
It's giving me the following APILibraryException error though:
Builder.setScheduleRequestedAt can only be called from within the same library group
My questions:
1) Is it setScheduleRequestedAt the right method to call if I want to delay the scheduling by diff_time?
2) If so, how can I solve this problem?
PS: diff_time is the difference, in milliseconds, to each of the corresponding hours of each day set by the user. Example: Monday-Friday = 08:00, Sat-Sun= 10:00.