user1796624
user1796624

Reputation: 4007

how to turn of gps when application stops in android application

I need to turn of the gps when the application stops, The gps is used globally and it is used in every Activity, how can I get an event when the app is closed?

Upvotes: 0

Views: 38

Answers (1)

Sunil Kumar
Sunil Kumar

Reputation: 7092

use use the remove the update on onPause it makes save the drain of battery

  @Override 
   protected void onPause() 
     { 
      super.onPause();
      if(locationmanager != null) { 
        locationmanager .removeUpdates(locationlistner); 
      } 
      locationlistner = null;  
    }

Upvotes: 1

Related Questions