Apps can't change that setting any more in recent versions of Android.
Well they still can in some rare circumstances, I think, like some
rooted phones.

In recent versions of Android just passing a large value for the
minTime parameter of the LocationManager#requestLocationUpdates will
do what you want automatically anyway. The GPS system will start, stay
up for a few fixes, then shutdown and set an alarm for when it should
start up again based on the minTime you passed.

Other apps may be registered for updates as well, however, which can
keep the GPS on, or make it come on more frequently. You can see
details in this thread:
http://groups.google.com/group/android-developers/browse_thread/thread/4bbd1593f41d1e97

If you want to do the same in older versions of Android you can just
set an alarm yourself. When you get the alarm you can register for
updates, then immediately remove updates once you have some, and wait
for the alarm again. Your app won't be registered for updates in
between alarms, so won't be responsible for keeping the GPS started. I
have heard of a bug that keeps the GPS on even when no apps are
registered for updates, but never ran into it myself.

On Mar 5, 8:02 pm, GG <[email protected]> wrote:
> I want to use GPS service for better accuracy in my program, but want
> the location only once in every couple of hours. To get GPS location
> the GPS had to be started already manually through Settings->Location
> Security->Use GPS Satellites. But the problem is GPS continuously
> running whether I need the location or not and drains the battery
> quickly. My question is what is the equivalent API for the checkbox
> selection of,
>
> Settings->Location Security->Use GPS Satellites
>
> appreciate your help.
>
> thanks,
> GG

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to