I use the following codes to get the location of user using FusedLocationApi however it seems that onLocationChanged really works when the location is really changed but not sends the initial location. When I start the Api nothing happens but when I change my location the target function is called.
This is how I start the Api:
@Override
public void onConnected(Bundle dataBundle) {
LocationServices.FusedLocationApi.requestLocationUpdates(mLocationClient, mLocationRequest, this);
}
And this is how I call my own function:
@Override
public void onLocationChanged(Location location) {
if (location != null) {
CurrentLocation=String.valueOf(location.getLatitude())+"_"+String.valueOf(location.getLongitude());
analyzeData(CurrentLocation);
}
}
How can I get the location as soon as onConnected
is fired not on location changes. Thanks