I have a WorkManager in my mainactivity:
private void startwork() {
PeriodicWorkRequest work = new PeriodicWorkRequest.Builder(AlarmReceiver.class, 16, TimeUnit.MINUTES)
.setConstraints(Constraints.NONE)
.build();
WorkManager.getInstance(MainActivity.this)
.enqueueUniquePeriodicWork("workname", ExistingPeriodicWorkPolicy.REPLACE, work);
}
I'd like to play an alert every 16 minutes. The problem is everytime user start the app it will show one alert immediately, I'd like to show the alerts only after 16 minutes the user open the app.
public Result doWork() {
notify();
}
Any ideas how to avoid this alert all the time that user opens the app, I'd like just to reschedule it to 16 minutes from now.