How to set system wide proxy in ICS

10,014

Solution 1

Unfortunately the hidden activity "com.android.settings.ProxySelector" is not designed for setting the proxy for Wi-Fi networks. In fact you can set a global proxy using this activity but for standard applications you won't see a change.

For example the default browser use this setting only for MOBILE networks and completely ignore it for Wi-Fi networks.

Of course you can read the settings in your personal app using this library, but you can't expect that other applications will do the same :(

Please let me know if everything is clear. Anyway I'm trying to cover the problem here, so you can find more resources on this topic.

Solution 2

if the device is rooted. you can edit the Iptable

Share:
10,014
Safecoder
Author by

Safecoder

Updated on June 04, 2022

Comments

  • Safecoder
    Safecoder almost 2 years

    For Android 3.x and before, you can bring up a hidden UI called com.android.settings.ProxySelector. It is set in Settings.Secure.HTTP_PROXY and used by Mobile network (WiFi network does not always work). However for ICS, I can still bring up this hidden UI, but it does not seem to set proxy anymore. When I click "Done", then I check Settings.Secure.HTTP_PROXY or system property http.proxyHost, neither is set.

    So is there a way in ICS that would allow me to set global proxy much like what I can do before with the com.android.settings.ProxySelector UI? Thanks!

  • Safecoder
    Safecoder almost 12 years
    Thankd Changwei. But I am looking for solutions for non-rooted devices.
  • Safecoder
    Safecoder almost 12 years
    This is not for my own phone. My phone is always rooted. :-)
  • Safecoder
    Safecoder almost 12 years
    Thanks, @LeChunk! What I noticed is that com.android.settings.ProxySelector does not work for mobile network either for ICS devices. Even after I set proxy in the UI, if I do Settings.Secure.getString(getApplicationContext().getContent‌​Resolver(), Settings.Secure.HTTP_PROXY), I will not get anything, meaning it was not really set. Did you see the same problem? I also do System.getProperty("http.proxyHost"), but also nothing.
  • Safecoder
    Safecoder almost 12 years
    Just modified my original post to be more clear that I am more concerned about mobile data side than Wifi side.
  • lechuckcaptain
    lechuckcaptain almost 12 years
    Unfortunately I don't have an ICS device with an official ROM installed. But I tried on an unofficial ICS ROM seems that the method: Settings.Secure.getString(getApplicationContext().getContent‌​Resolver(), Settings.Secure.HTTP_PROXY) always return null. Don't know why. This is another clue that confirm that we shouldn't use the com.android.settings.ProxySelector activity on newer versions.
  • Safecoder
    Safecoder almost 12 years
    Yes, that's what I see on my device as well. I also tried ICS emulator and same behavior. So this activity has no effect now? Then how can I set proxy for mobile network then? Some carriers don't have APN that the user can edit.
  • lechuckcaptain
    lechuckcaptain almost 12 years
    I think that you just need to edit the APN settings into your device.
  • Safecoder
    Safecoder almost 12 years
    But some carriers don't allow customers change APN directly. I did some more research and it seems that Android deprecated Settings.Secure.HTTP_PROXY in ICS with global_http_proxy_host but I could not find anything about it. Just posted another question on this. stackoverflow.com/questions/10611381/…
  • Adam
    Adam over 11 years
    Check out this answer for some more details on Android's Proxy situation: stackoverflow.com/questions/10811698/…