Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.