Answer the question
In order to leave comments, you need to log in
GPS in Android
Good day, dear Khabravchane.
Can you please tell me how to programmatically enable and disable GPS in Android 2.2? The application should turn on the GPS and work with it when the user pressed the corresponding button in the application, and turn it off by another button. Now I turn on the GPS in the settings manually and work with it, but when I exit the application, the GPS remains active and drains the battery.
Answer the question
In order to leave comments, you need to log in
As I understand it, you need to dig towards onProviderEnabled.
Here is an example where GPS is enabled:
advback.com/android/checking-if-gps-is-enabled-android/
But everything is as intended, you need to turn on GPS in the settings, as well as Wi-Fi for example. This is not only in Android 2.2, but in all the following
groups.google.com/group/android-developers/browse_thread/thread/fec09ede096238e8/2738ff50f76cc739?lnk=gst&q=gps
Nizya.
khaki in the garden. Works on one phone, not on the other.
Display system activity with a toggle.
I think you are confusing something. What's in the settings is not to enable / disable GPS, but to allow / forbid applications to use it. The applications themselves turn GPS on and off when they need it (if it is not prohibited in the settings). See, for example, how other applications work, for example, the standard maps - you logged in, GSP turned on, logged out - turned off. If GPS is “enabled” but not used, the battery should not be wasted.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question