0

I know it is a mess when it comes to proxy support in Android and a lot of frustration too. I read most of posts on SO and I am still confused.

I would like to support both Wifi proxy and mobile proxy and I know that there has been some changes in proxy support prior to honeycomb and post honeycomb. I also read that you need to be a system app to set proxy even if you have the android.permission.WRITE_SECURE_SETTINGS permission.

So can i set system proxy for wifi and mobile network from my application? Any difference before honeycomb and after honeycomb?

What's the preferred way to get proxy settings for wifi and mobile network? Any difference before honeycomb and after? If I want to use it in my app, is it simple as setting proxy parameter on the httpClient object? Anything else I need to do? Or should I use system property?

Please consider the case where Wifi and mobile proxy could be different.

Any pointer to a good document on this (updated to reflect changes since honeycomb) would be very helpful. I did not find any good ones.

Safecoder
  • 1,035
  • 2
  • 17
  • 32

2 Answers2

1

So can i set system proxy for wifi and mobile network from my application?

No, unless your app is part of the firmware.

Any difference before honeycomb and after honeycomb?

Not with respect to whether or not you can set them.

What's the preferred way to get proxy settings for wifi and mobile network?

AFAIK, there is only one accessible proxy setting, Settings.Secure.HTTP_PROXY, which you get via a call to getString() on Settings.Secure.

Any difference before honeycomb and after?

Not that I am aware of.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks, CommonWare! So using Setting.Secure do you get Wifi proxy or mobile proxy? My understanding is that it is only for the mobile network. on Honeycomb and ICS, you can set wifi proxy or even wifi proxy for each wifi hotspot. Do you know how to handle that in my code? Couldn't find any good docs. – Safecoder Feb 04 '12 at 18:54
  • 1
    @HowardLi: "on Honeycomb and ICS, you can set wifi proxy or even wifi proxy for each wifi hotspot" -- I see no evidence of this in the SDK or on actual hardware. – CommonsWare Feb 04 '12 at 18:59
  • I have android tablet and it is running 3.2 (I have not tried ICS). So if you go to wifi settings, long click the hotspot/SSID, then you see a popup, select manually modify (second from the list), then you can set wifi proxy for it. I don't have the device with me now so I am typing it based on my memory. Some details might be slightly off, but I am sure you can do it. – Safecoder Feb 04 '12 at 19:08
  • @HowardLi: None of that is documented; I have no idea what it means. Sorry. – CommonsWare Feb 04 '12 at 19:11
1

With reflection you can get the proxy settings for each Wi-Fi access point. It's what this library does. You can use it to easily access the proxy settings for the current configuration.

lechuckcaptain
  • 1,032
  • 1
  • 9
  • 25
  • Thanks, LeChuck! Sorry I did not notice that I have a new answer until now. I just downloaded your latest APL and tried your test app. It listed all the APs, but all of them say NOT SET. I know one of them have proxy setting. So I need to take a closer look at your code to see why it is not working. BTW, I am using Moto Xoom to test it because I think APL only works for API level >=11. Any suggestions would be appreciated. Your blog is also very informative . Thanks! – Safecoder Mar 03 '12 at 08:11
  • Also, I just posted another question regarding proxy, appreciate it if you can take a look and shed some light http://stackoverflow.com/questions/9544582/how-android-application-decide-if-they-want-to-use-network-proxy-or-not – Safecoder Mar 03 '12 at 08:12
  • Yes, you are right. Proxy settings per AP were introduced since API level >= 11. For devices with API version lower < 11, it's still unclear to me how a user or a developer can set the proxy settings. Actually I still have this unanswered questions http://stackoverflow.com/questions/9446871/how-users-developers-can-set-the-androids-proxy-configuration-for-versions-2-x- . I hope some Googlers will answer (If you are interested on the topic, just vote it!) – lechuckcaptain Mar 03 '12 at 11:56
  • Just up voted it. I double any googlers will answer it :-) I think they all got order from their big boss not comment on anything that's not in the sdk. – Safecoder Mar 03 '12 at 19:42
  • 1
    Well, actually the ProxySelector class is into the SDK. We just need to understand how it works for devices with API level < 11. It's a small effort for someone who really knows how the system work, but a big gift for us, the developers. – lechuckcaptain Mar 04 '12 at 15:49