On Mar 9, 1:20 pm, Rudi <rudolf.hor...@gmail.com> 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 from http://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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to