Guest User

Untitled

a guest
Oct 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. Driver driver = new GooglePlayDriver(context);
  2. FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(driver);
  3.  
  4. Job myJob = dispatcher.newJobBuilder()
  5. // the JobService that will be called
  6. .setService(MyJobService.class)
  7. // uniquely identifies the job
  8. .setTag("complex-job")
  9. // one-off job
  10. .setRecurring(false)
  11. // don't persist past a device reboot
  12. .setLifetime(Lifetime.UNTIL_NEXT_BOOT)
  13. // start between 0 and 15 minutes (900 seconds)
  14. .setTrigger(Trigger.executionWindow(0, 900))
  15. // overwrite an existing job with the same tag
  16. .setReplaceCurrent(true)
  17. // retry with exponential backoff
  18. .setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
  19. // constraints that need to be satisfied for the job to run
  20. .setConstraints(
  21. // only run on an unmetered network
  22. Constraint.ON_UNMETERED_NETWORK,
  23. // only run when the device is charging
  24. Constraint.DEVICE_CHARGING
  25. )
  26. .build();
Add Comment
Please, Sign In to add comment