Im trying to make an app for android wear that shows real time location of the user in a map. Im using LocationServices.FusedLocationApi.requestLocationUpdates for get location updates using this location request:
protected void createLocationRequest() {
mLocationRequest.setInterval(3000);
mLocationRequest.setFastestInterval(1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
@Override
public void onResume() {
mMapFragment.onResume();
super.onResume();
checkPermission();
LocationServices.FusedLocationApi.requestLocationUpdates(
mApiClient, mLocationRequest, this);
}
@Override
public void onPause() {
super.onPause();
LocationServices.FusedLocationApi.removeLocationUpdates(mApiClient,this);
}
In OnCreateView i call the createlocationRequest method.
What i expected was that every time the location change, the onLocationChanged method of the listener was call. Instead of that, it only call onLocationChanged each time the app is in onResume (because is where i have LocationServices.FusedLocationApi.requestLocationUpdates).
I have the permissions in the Manifest
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
This class where im asking for location updates is a Fragment where i have the map, i dont know if that affects.