Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
//location obtained, need to send it to server
private void broadcastLocation(Location location) {
//release latch
//We need to sure that device have internet live
Constraints constraints = new Constraints.Builder().setRequiredNetworkType
//Parse our location to Data to use it as input for our worker
Data inputData = new Data.Builder()
.putDouble(LocationUploadWorker.LOCATION_LAT, location.getLatitude())
.putDouble(LocationUploadWorker.LOCATION_LONG, location.getLongitude())
.putLong(LocationUploadWorker.LOCATION_TIME, location.getTime())
//worker itself
OneTimeWorkRequest uploadWork = new OneTimeWorkRequest.Builder
//Schedule it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment