質問

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