android - How to avoid the battery drain while implementing the GPS? -


in app i'm using gps listener. need turn off gps , activate later. i'm using

locationmanager.removeupdates(locationlistener);

to turn off gps. turn gps off. later i'm not able turn on? there other methods turn off gps?

for activating gps i'm using

locationmanager.requestlocationupdates(locationmanager.gps_provider, updatesinterval, 0, locationlistener); 

you can make service implement location listener when ever want start location listener can start service , put

ocationmanager.requestlocationupdates(locationmanager.gps_provider, updatesinterval, 0, locationlistener); 

line in oncreate() method

and when want close location update stop service , put line

locationmanager.removeupdates(locationlistener); 

to ondistroy() method


Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -