Skip to content

Instantly share code, notes, and snippets.

@Suchiq
Created August 1, 2022 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Suchiq/e3c78176abaccb1795684b725d5c5040 to your computer and use it in GitHub Desktop.
Save Suchiq/e3c78176abaccb1795684b725d5c5040 to your computer and use it in GitHub Desktop.
//creating constraints
Constraints constraints = new Constraints.Builder()
.setRequiresCharging(true) // you can add as many constraints as you want
.build();
final OneTimeWorkRequest workRequest =
new OneTimeWorkRequest.Builder(MyWorker.class)
.setInputData(data)
.setConstraints(constraints)
.build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment