M
M
mastersoftna2011-07-22 11:01:15
satellite navigation
mastersoftna, 2011-07-22 11:01:15

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

5 answer(s)
O
Oleg Matrozov, 2011-07-22
@mastersoftna

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/

I
Igor Ivanchenko, 2011-07-22
@evgsd

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

N
nd0ut, 2011-07-22
@nd0ut

groups.google.com/group/android-developers/browse_thread/thread/fec09ede096238e8/2738ff50f76cc739?lnk=gst&q=gps

H
hudvin, 2011-07-22
@hudvin

Nizya.
khaki in the garden. Works on one phone, not on the other.
Display system activity with a toggle.

Z
Zigmar, 2011-07-23
@Zigmar

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 question

Ask a Question

731 491 924 answers to any question