Skip to content

Instantly share code, notes, and snippets.

@parahall
Created May 10, 2018 06:01
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 parahall/1a42f7663aa679bacb97f268a20c13be to your computer and use it in GitHub Desktop.
Save parahall/1a42f7663aa679bacb97f268a20c13be to your computer and use it in GitHub Desktop.
Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType
.CONNECTED).build();
Data inputData = new Data.Builder()
.putDouble(LocationUploadWorker.LOCATION_LAT, location.getLatitude())
.putDouble(LocationUploadWorker.LOCATION_LONG, location.getLongitude())
.putLong(LocationUploadWorker.LOCATION_TIME, location.getTime())
.build();
OneTimeWorkRequest uploadWork = new OneTimeWorkRequest.Builder(LocationUploadWorker.class)
.setConstraints(constraints).setInputData(inputData).build();
WorkManager.getInstance().enqueue(uploadWork);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment