Due to the way our app works, I need to synchronously get the users current location. Our current implementation uses the com.google.android.gms.location.LocationListener
to receive location updates. Problem is, I need to update the location server-side before attempting my first call, otherwise the user gets faulty data.
LocationServices.FusedLocationApi.getLastLocation()
isn't suited for this, because a) it always seems to return null (for whatever reason) and b) we already save the users last known location server-side, so retrieving the last known location and sending it to the servers is redundant.
pseudocode
//this is the first call I need to make
webservice.appStart(AppStartBody body);
//then I want to retrieve the current location and send it to the server
webservice.setGeoLocation(getCurrentLocation());
//finally, I retrieve the items on the server based on the location
webservice.getListItems();
Waiting for the first location update event is a possibility that I want to avoid, because I don't know, how soon it will fire and I might have to keep my users in a loading screen for ages and in turn lose them, because nobody likes waiting.