Skip to content

Instantly share code, notes, and snippets.

@adriantache
Created May 22, 2018 09:30
Show Gist options
  • Save adriantache/e20d4a74c522e6cfa1f2f94b1f9e9153 to your computer and use it in GitHub Desktop.
Save adriantache/e20d4a74c522e6cfa1f2f94b1f9e9153 to your computer and use it in GitHub Desktop.
Work Request
//we set a tag to be able to cancel all work of this type if needed
public static final String workTag = "notificationWork";
//store DBEventID to pass it to the PendingIntent and open the appropriate event page on notification click
Data inputData = new Data.Builder().putInt(DBEventIDTag, DBEventID).build();
// we then retrieve it inside the NotifyWorker with:
// final int DBEventID = getInputData().getInt(DBEventIDTag, ERROR_VALUE);
OneTimeWorkRequest notificationWork = new OneTimeWorkRequest.Builder(NotifyWorker.class)
.setInitialDelay(calculateDelay(event.getDate()), TimeUnit.MILLISECONDS)
.setInputData(inputData)
.addTag(workTag)
.build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment