문제

I am developing an app. in which I share my location with friends (very much like google latitude). I have a service which is running as daemon: it should display received locations, and publish current user location each x seconds.

Now, being quite new to Android and Maps, I am a bit confused about MyLocationOverlay and LocationManager.

While experimenting with the MapActivity, I am using MyLocationOverlay which seems very handy to display my location. Problem is, I am not sure where it is taking the location from (net, gps,.. ?) and how often it updates it. Moreover, I suppose I cannot use it outside the MapActivity, hence I'll need to use the LocationManager anyway.

The question is: using the LocationManager to do the background work and MyLocationOverlay to only show my location would be too much? I suppose it would be better to only use the LocationManager, right?

도움이 되었습니까?

해결책

Using MyLocationOverlay in conjunction with LocationManager is very common. MyLocationOverlay determines location from GPS, then Wifi. You can specify the networks to use for location determination both for MyLocationOverlay and with a LocationManager.

The location is stored for both types of location finding (in other words, if you have a MyLocationOverlay as well as LocationManager, it's not going to poll the GPS twice as hard, its simply going to use the last-received location for both). The last location received by GPS or wifi is stored globally to any application that determines a location.

So to answer your question, no, using a LocationManager as well as a MyLocationOverlay is not too much.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top