Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Driver driver = new GooglePlayDriver(context);
- FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(driver);
- Job myJob = dispatcher.newJobBuilder()
- // the JobService that will be called
- .setService(MyJobService.class)
- // uniquely identifies the job
- .setTag("complex-job")
- // one-off job
- .setRecurring(false)
- // don't persist past a device reboot
- .setLifetime(Lifetime.UNTIL_NEXT_BOOT)
- // start between 0 and 15 minutes (900 seconds)
- .setTrigger(Trigger.executionWindow(0, 900))
- // overwrite an existing job with the same tag
- .setReplaceCurrent(true)
- // retry with exponential backoff
- .setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
- // constraints that need to be satisfied for the job to run
- .setConstraints(
- // only run on an unmetered network
- Constraint.ON_UNMETERED_NETWORK,
- // only run when the device is charging
- Constraint.DEVICE_CHARGING
- )
- .build();
Add Comment
Please, Sign In to add comment