I searched it over the internet and found this link. I followed it but it didn't work. So I looked at logcat which told me this:
Setting http_proxy has moved from android.provider.Settings.System to android.provider.Settings.Secure, value is unchanged.
So I added
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
to the menifest and in my code, I changed to
Settings.System.putString(getContentResolver(), Settings.Secure.HTTP_PROXY, "127.0.0.1:8080");//enable proxy
and
Settings.System.putString(getContentResolver(), Settings.Secure.HTTP_PROXY, "");//disable proxy
but still I get the same setting moved
error. What am I missing?
I saw the question How can I get the dreaded WRITE_SECURE_SETTINGS permission for my android app? also which says I can't get this permission. Is that true? And come on, I'm just changing proxy setting! Why am I not allowed to do so? At least, can I direct user to somewhere he can himself change proxy, like we do for enabling bluetooth?