Android / location:

I would like to receive location updates every 5 seconds.

Should I call the method:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,5000, 0, gpsLocListener)?

It is important for me NOT to interfere with the osmdroid MyLocationManager functionality. Or should I use the MyLocationOverlay.onLocationChanged(), e.g. by inheritance of the MyLocationOverlay class.

If so, how often will it be called?

有帮助吗?

解决方案

There should be no problem having multiple listeners on the location manager. Each one will get events separately. In fact, if you wanted you could use a new instance of osmdroid's GpsMyLocationProvider to feed you location updates. Call mGpsMyLocationProvider.startLocationProvider(myLocationConsumer) where myLocationConsumer is an instance of IMyLocationConsumer that receives and handles gps updates as you wish. You can call mGpsMyLocationProvider.setLocationUpdateMinTime() to adjust how often you get updates.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top