Skip to content

Instantly share code, notes, and snippets.

@parahall
Created May 10, 2018 17:37
Show Gist options
  • Save parahall/e79111e235bf0b02ac7177ae2f7ff548 to your computer and use it in GitHub Desktop.
Save parahall/e79111e235bf0b02ac7177ae2f7ff548 to your computer and use it in GitHub Desktop.
public class LocationUploadWorker extends Worker {
//...
public WorkerResult doWork() {
//get Data out from input
double longitude = getInputData().getDouble(LOCATION_LONG, 0);
double latitude = getInputData().getDouble(LOCATION_LAT, 0);
long time = getInputData().getLong(LOCATION_TIME, 0);
String osVersion = "WorkerReport v" + Build.VERSION.SDK_INT;
//construct our report for server format
ServerReport serverReport = new ServerReport(longitude, latitude, time);
//Report it to firebise server
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference(osVersion);
myRef.push().setValue(serverReport);
return WorkerResult.SUCCESS;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment