views:

257

answers:

1

I'd like to write a simple widget that toggles GPS and network location on and off. I've read that it's not possible to do that normally, but presumably on a rooted phone it must be doable. Does anyone know what the code would be? (I only need the code to toggle the location providers, I know how to make the widget.) It doesn't matter that this isn't a 'good' solution, I don't plan to distribute the widget. If it matters, this would be on an HTC Hero, still running v1.5.

+1  A: 

I suspect you are looking for LOCATION_PROVIDERS_ALLOWED in android.provider.System.Secure. However, I'm not sure root access will be sufficient to let you invoke those from an SDK application. The relevant methods to modify that setting might be protected by checking the digital signature of the SDK application. AFAIK, that would require you to build and sign your own firmware, then sign the SDK application to match.

You might also be able to figure out what happens in the system when that setting is adjusted, and see if there is a way to affect the same change, via an SDK app on a rooted device, without going through the Secure content provider.

CommonsWare
Thanks for the suggestions. However I'm not sure I follow point 2 - what do you mean by an "SDK app"?
Steve H
An "SDK app" is an app written using the Android SDK. That's in contrast to modifying the Android firmware itself, where you are not limited to what is public.
CommonsWare