I'm using the LocationClient to get the user location from the network (no gps).
I instantiate the LocationClient during the creation of my fragment
mLocationClient = new LocationClient(getActivity(), this, this);
mLocationClient.connect();
And then later
if (mLocationClient.isConnected())
{
currentLocation = mLocationClient.getLastLocation();
}
I am sure that it is connected, but the getLastLocation() returns null always.
However, it works using the LocationManager.
LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
currentLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
I know I could just use a listener for location updates, but I would like to understand why getLastLocation() always returns null.