Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[Q] Enable GPS

OP mist3r0

26th October 2010, 01:14 PM   |  #1  
OP Member
Thanks Meter: 1
 
30 posts
Join Date:Joined: Jul 2010
Hello Guys,

I'm a beginner android programmer.

I want to active directly GPS, same the Power Control android Widget.

I've saw this code of android kernel (http://android.git.kernel.org/?p=pla...48cfaad8c65324)

I nedd to enable or disable GPS, when i click a button.

I've write this code:

booelan gpsStatus = locmanager.isProviderEnabled(LocationManager.GPS_P ROVIDER);

(!gpsStatus){

Settings.Secure.setLocationProviderEnabled(getCont entResolver(), LocationManager.GPS_PROVIDER, true);

}

and I've put into manifest file the following permissions:

<uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission>

<uses-permission android:name="android.permission.WRITE_SECURE_SETT INGS"></uses-permission>

but when execute my code, the system send me this error:

java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS

but I've already inser into the manifest file this permission!!!


Can you help me?? Please, it's very important!!!

Thank you!
26th October 2010, 03:04 PM   |  #2  
Recognized Contributor
Flag Brighton IL
Thanks Meter: 552
 
1,667 posts
Join Date:Joined: Jul 2010
More
Some phones disable WRITE_SECURE_SETTINGS in their "default.prop" file which is stored in the boot partition so you need root and a lot of other utilities to change it. Here is is on the HTC Aria:

Code:
#
# ADDITIONAL_DEFAULT_PROPERTIES
#
ro.secure=1
ro.allow.mock.location=0
ro.debuggable=1
persist.service.adb.enable=1
Last edited by Gene Poole; 26th October 2010 at 03:17 PM.
26th October 2010, 07:22 PM   |  #3  
OP Member
Thanks Meter: 1
 
30 posts
Join Date:Joined: Jul 2010
I've tested this code on HTC DESIRE with root permission, but this code don't work!!
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes