FORUMS
Remove All Ads from XDA

[Q] Enable GPS

31 posts
Thanks Meter: 1
 
By mist3r0, Member on 26th October 2010, 12:14 PM
Post Reply Email Thread
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, 02:04 PM |#2  
Recognized Contributor
Flag Brighton IL
Thanks Meter: 564
 
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
26th October 2010, 06:22 PM |#3  
OP Member
Thanks Meter: 1
 
More
I've tested this code on HTC DESIRE with root permission, but this code don't work!!
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes