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

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -