Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MyLocationOverlay or LocationManager for updating current location

I am using MapView to show current location of a user on a Map. To update the location while the user is on the move, I have to a choice:

  • I can use MyLocationOverlay to draw the current location and extend it to allow tracking of the users location on the move and to have custom marker. The problem with MyLocationOverlay is that I cannot control the frequency with which the device requests the location from GPS. I am worried about the battery drain here.
  • I can use Location Manager and subscribe using requestLocationUpdates to get location from GPS. Here I have more control over the frequency with which the GPS is queried. I can hook up a LocationListener and write the code in there.

But I have read here at SO that it might not be good approach to use Location Manager and MyLocationOverlay should be preferred over to this.

Also, consider that my app is a location based app the location of the user should be tracked as he moves.

Can people suggest which is the best approach to implement and has relatively less impact on battery.

Note that I am a beginner in Android, so pardon any obvious mistakes.

Thank you in advance, andy

like image 638
andy Avatar asked Jul 05 '12 10:07

andy


1 Answers

I using Little Fluffy Location - Its a library, you setting time for updates or distance, this library make a broadcast receiver, implements LocationListener, n notify your application when location changes.

Simple, fast, easy!

Please refer this link:

After location changed, update your overlay on the map! =)

if you need, i send my full solution for locations.

like image 148
Pierry Avatar answered Nov 09 '22 12:11

Pierry