Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,738,368 Members 51,404 Now Online
XDA Developers Android and Mobile Development Forum

[Q] Enable GPS

Tip us?
 
mist3r0
Old
#1  
Member - OP
Thanks Meter 1
Posts: 30
Join Date: Jul 2010
Question [Q] Enable GPS

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!
 
Gene Poole
Old
(Last edited by Gene Poole; 26th October 2010 at 02:17 PM.)
#2  
Recognized Contributor
Thanks Meter 551
Posts: 1,667
Join Date: Jul 2010
Location: Brighton IL
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:
Select Code
#
# ADDITIONAL_DEFAULT_PROPERTIES
#
ro.secure=1
ro.allow.mock.location=0
ro.debuggable=1
persist.service.adb.enable=1
 
mist3r0
Old
#3  
Member - OP
Thanks Meter 1
Posts: 30
Join Date: Jul 2010
I've tested this code on HTC DESIRE with root permission, but this code don't work!!
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes