Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPS icon is still blinking after locationManager.removeUpdates() and by setting locationManager to null

I am developing the Location Tracking application. But i am stopping getting the location update by doing 2 things...

  1. locationManager.removeUpdates(this); and
  2. setting locationManager reference to null.

This will stop getting location co-ordinates as i want...

But the problem is the gps icon is still blinking.. which will draining the device's battery.

So please help me in stopping this GPS fixes...

like image 924
NullPointerException Avatar asked Apr 13 '12 13:04

NullPointerException


1 Answers

If you display your position and/or the compass in your mapView, you have to disable them. If you don't do that, GPS is still active.

Ex :

private MapView mapView;
private MyLocationOverlay Location;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.frame_layout);

    mapView = (MapView) this.findViewById(R.id.mapView);
    Location = new MyLocationOverlay(this, mapView);
    Location.enableMyLocation();
    Location.enableCompass();
    mapView.getOverlays().add(Location);
}

@Override
public void onDestroy() {
    Location.disableMyLocation();
    Location.disableCompass();
}
like image 152
JoMoX909 Avatar answered Sep 21 '22 21:09

JoMoX909