Issue
Currently I display user's location at MapView:
MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableMyLocation();
But once user closes MapView
activity (press back button) or even closes MainActivity
(presses back again), GPS icon is still displayed in the status bar. Looks like GPS is still used. Should I do something in my code to avoid that?
Solution
Yes you need to stop GPS usage to avoid battery draining, following methods will stop GPS usage used in relevant methods like OnPause, onStop, onDestroy:
MyLocationOverlay.disableMyLocation();
LocationManager.removeUpdates(LocationListener);
Answered By - Vinayak Bevinakatti
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.