Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Enable and Disable GPS [duplicate]

Tags:

android

gps

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 android "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?? –

like image 856
mist3r0 Avatar asked Oct 25 '10 13:10

mist3r0


People also ask

How enable and disable GPS programmatically in Android?

This example demonstrates how do I get enable/disable GPS programmatically in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do I turn on GPS automatically on Android?

Open your phone's Settings app. Under "Personal," tap Location access. At the top of the screen, turn Access to my location on or off.

How do I open location settings in android programmatically?

Get current location settingsTask<LocationSettingsResponse> task = client. checkLocationSettings(builder. build()); When the Task completes, your app can check the location settings by looking at the status code from the LocationSettingsResponse object.


1 Answers

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).

like image 176
kgiannakakis Avatar answered Sep 29 '22 06:09

kgiannakakis