Remove All Ads from XDA

[Q] Enable GPS

31 posts
Thanks Meter: 1
By mist3r0, Member on 26th October 2010, 01: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 (

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


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  
Senior Member
Flag Brighton IL
Thanks Meter: 564
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:

26th October 2010, 07:22 PM |#3  
OP Member
Thanks Meter: 1
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)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes