i have a problem with the work request (1.0.0-alpha10) Let say if i want to launch a work (in my case a notification) every 5 hours i do the following
static void StartWorker(){
PeriodicWorkRequest workRequest = new PeriodicWorkRequest.Builder(NotifyWorker.class, 5, TimeUnit.HOURS,3000,TimeUnit.MILLISECONDS)
.addTag("ok")
.build();
}
But the problem is that the notification start even after 20 minutes, is weird because is like is really random, i understand that can't pass exactly 5 hours between two notifications but anticipate it of 4:30 hours is a little too much.
The NotifyWorker class is like this:
public class NotifyWorker extends Worker {
public NotifyWorker(@NonNull Context context, @NonNull WorkerParameters params) {
super(context, params);
}
@NonNull
@Override
public Worker.Result doWork() {
// Method to trigger an instant notification
Context context= getApplicationContext();
notification();
return Worker.Result.SUCCESS;
}
}
What i'm doing wrong? I'm using a Galaxy S8 with Android 8.0.0 for debugging.