0

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.

  • 1
    Provide location-related code sections in your Fragment – merterpam Aug 20 '17 at 15:18
  • Done. I create the location request in the oncreateview of the fragment. For example if i start the app it goes to onResume and the onLocationChanged get call, and if i put the app in background and get back to it it goes to onRenume and location updates. That the only time it detects an update. – Ana Gonzalez Garcia Aug 20 '17 at 16:19

0 Answers0