Search code examples
androidosmdroid

Osmdroid MylocationNewOverlay - setting the location update frequency


Is there a way to set the location update frequency? And also for the minimum distance?

Reason: I would like to set it in relation to battery savings.


Solution

  • You can create your own instance of GpsMyLocationProvider and set those parameters.

    GpsMyLocationProvider gpsLocationProvider = new GpsMyLocationProvider(context);
    gpsLocationProvider.setLocationUpdateMinTime(...);
    gpsLocationProvider.setLocationUpdateMinDistance(...);
    mMyLocationNewOverlay.enableMyLocation(gpsLocationProvider);