Android Enable and Disable GPS [duplicate]
Possible Duplicate:
Enable GPS programatically like Tasker
I'm a beginner android developer.
I want enable and disable GPS with a click of a button, without running this intent:
intente in = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(in);
that brings me in the setting menu.
Is there a method to enable or disable GPS as in the an开发者_开发问答droid "Power Control" widget?
Thanks
EDIT:
The widget that I said is in the android system (version 1.6 on forward). There is an application (siriusapplications.com/powercontrolplus) that make want I want do, and extend the android power control.. my question is: how this persor can manage this?? –
I don't think there is a way to do so. See this question. You can also find a nice example here. Basically what you do is test if GPS is enabled and then navigate user to the appropriate settings page.
The widget you are referring to probably has direct access to the GPS driver. This means that will only work in the device at hand (or in a single family of devices).
the GPS can be toggled by exploiting a bug in the power manager widget. see this question.
精彩评论