java - Turning on and off GPS programmatically in all android version -


i working on location based application. want turn on/off gps through code. found solution [link]: turning on , off gps programmatically in android 4.0 , above? app crashing when run portion. please guide me proper solution.

i want turn on/off gps through code

there "enabled/disabled", , there "on/off". "enabled/disabled" determines whether app can gps fixes. "on/off" determines whether device trying gps fixes right now. gps can "on" if "enabled".

if request locations gps_provider, , gps enabled, gps radio turn on. if stop requesting locations gps_provider, , no other app requesting locations gps_provider, gps radio turn off. depending on how configure request locations (e.g., once hour), gps radio may turn off , on save battery life, while request outstanding. hence, android developers not worry "on/off" — developers request locations, , hardware takes care of powering on , off gps radio needed.

your link refers "enabled/disabled". android removed ability apps enable , disable gps in android 1.5, privacy reasons. malware authors have continued try find ways around this, because malware authors not interested in user privacy. link cited exploit flaw in android allowed apps enable , disable gps. exploit fixed years ago. not aware of current exploit allows apps enable , disable gps.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -