Android java.lang.SecurityException on Settings.Se

2019-07-16 04:15发布

问题:

I'm trying to set a system property in Android 2.2. Using Android for eclipse plug-in. The line that's causing the exception is:

Settings.Secure.putString(getContentResolver(),
                          Settings.Secure.HTTP_PROXY, "127.0.0.1:8099")

And while running in the emulator I'm getting:

08-01 22:48:44.338: ERROR/DatabaseUtils(58): java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS

I have already in my AndroidManifest.xml the following lines in front of the 'application' tag:

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

What else am I missing?

回答1:

Non-system applications aren't allowed to use the WRITE_SECURE_SETTINGS permission.