This flavor of proxy support in Android didn't appear until Honeycomb (3.1). Prior to that there was the Proxy class in the framework that reported a network-independent "global proxy".
On Mon, Aug 26, 2013 at 7:16 AM, TG <[email protected]> wrote: > I am using a Samsung Galaxy S Plus Phone running on Android 2.3.4 > > I manually set the proxy server and the port in the phone, in Settings-> > Wireless & Network-> Wi-Fi Settings-> MENU Button-> Advanced panel. > > My phone is still not able to communicate using the proxy. I tried the > browser, and that is not able make use of the proxy settings. > > public static InputStream inputStreamForUrl(URL url) throws IOException { > > HttpURLConnection urlConnection = (HttpURLConnection) > url.openConnection(); // doesn't work on android 2.3.4 > urlConnection.setRequestMethod("GET"); > urlConnection.setDoInput(true); > urlConnection.setConnectTimeout(30000); > urlConnection.setReadTimeout(30000); > System.out.println(urlConnection.usingProxy()); > urlConnection.connect(); > return urlConnection.getInputStream();} > > However, If I manually hardcode the proxy in the code, it works > > Proxy proxy = new Proxy(Proxy.Type.HTTP, new > InetSocketAddress("proxy.server.url", 8080));// this needs to be hard coded > to make it work in 2.3HttpURLConnection urlConnection = (HttpURLConnection) > url.openConnection(proxy);// this needs to be hard coded to make it work in > 2.3 > > I tried to dynamically find out the system proxy and then use it in code, > > private static void getProxySettings() > { > final boolean IS_ICS_OR_LATER = Build.VERSION.SDK_INT >= 14; > > String proxyAddress = ""; > int proxyPort = 0; > > if( IS_ICS_OR_LATER ) > { > proxyAddress = System.getProperty( "http.proxyHost" ); > > String portStr = System.getProperty( "http.proxyPort" ); > proxyPort = Integer.parseInt( ( portStr != null ? portStr : "-1" > ) ); > } > else > { > proxyAddress = android.net.Proxy.getHost( ctx ); > proxyPort = android.net.Proxy.getPort( ctx ); > } > > > > System.out.println(proxyAddress); > System.out.println(proxyPort); > } > > but the proxy address and port is null always. > > Can someone help please > > *PS.* I absolutely no problem on Android 4.1/4.2/4.3 devices > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

