Actually I'm building from my own source tree and was
calling updateManager. I was able to turn on the GPS successfully
at the start of my activity....

Now the problem is that I want to restore the original state when my
activity
is paused. So I'm doing exactly the same thing in my onPause method,
but the android throws on me a SecurityException about.
The strange thing is that the same code works for turning on the GPS
at application start, but fails with security exception at the end...

I was hoping that there were better ways turn on/off the GPS, than
calling
internal API-s... :(

Thanks for the answers..
Rudolf

On márc. 10, 05:17, Edward  Falk <[email protected]> wrote:
> On Mar 9, 1:20 pm, Rudi <[email protected]> wrote:
>
> > What is the correct way of turning ON/OFF the GPS in Android. I've
> > found the System.Settings provider, and the LOCATION_PROVIDERS_ALLOWED
> > setting, but it seems that the rest of the system is not notified
>
> I had the exact same question myself.  Browsing the source code for
> the settings application shows that it's calling
> locationManager.updateProviders() to send the notification out.
>
> Unfortunately, this API isn't available unless you're building within
> the Android source tree.
>
> Your options seem to be:
>
> 1) Ignore the problem.  Things should still work, except for the
> notifications.
>
> 2) Wait for Google to open up the updateProviders() api, then update
> your code accordingly.
>
> 3) Use this code snippet fromhttp://habrahabr.ru/blogs/android/46356/:
>
>     try {
>       Method m =
>         locationManager.getClass().getMethod("updateProviders", new
> Class[] {});
>       m.setAccessible(true);
>       m.invoke(locationManager, new Object[]{});
>     } catch (Exception e) {
>       Log.e(TAG, "Couldn't call updateProviders", e);
>     }
>
> I can't vouch for #3.  I'm sticking to #2 myself.
--~--~---------~--~----~------------~-------~--~----~
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