Im using GoogleMap.OnMyLocationChangeListener to get the current location (below)
private GoogleMap.OnMyLocationChangeListener myLocationChangeListener = new GoogleMap.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(Location location) {
start = new LatLng(location.getLatitude(), location.getLongitude());
map.addMarker(new MarkerOptions().position(start));
}
};
However, I need a way to wait for the listener to complete. Reason being that, Start var will obviously be null if I continue to execute other code without location data. I thought that AsyncTask might be useful here, but have no idea what to call inside doInBackground/onPostExecute.
map.setOnMyLocationChangeListener(myLocationChangeListener); // set the listener
// perform wait and initiate start variable
String url = getDirectionsUrl(start, destination);
// a sync task here using the url
Any hints or code snippets would be much appreciated~!