Android Emulator and Proxy

by Nirmal Patel » Fri, 18 Mar 2011 14:47:35 GMT

Sponsored Links
 I am confused with how the Proxy settings work in the Android emulator.

I am able to access internet in the browser by configuring my Proxy settings 
on the APN (TelKila)
However, my App is not able to access internet. (uses-permission mentioned 
in AndroidManifest.xml)

I am using HttpClient in my app to make a web service call which fails with 
a UnknownHostException.
To access internet through HttpClient; I have to add proxy settings to 
HttpClient explicitly in my code.

Shouldn't HttpClient pick up the proxy settings configured on the APN?? 


Re: Android Emulator and Proxy

by Ramsay Domloge » Fri, 18 Mar 2011 19:12:26 GMT

 When you say 'HttpClient', I assume you mean Apache HTTPClient?

If so, this is a toolkit for accessing HTTP content from a Java context, 
whether Java is running in Android, in a Java applet running in Firefox on 
Windows or running in a backend Unix Application server. HttpClient is not 
specific to Android and therefore doesn't intrinsicly know how to 'talk' to 
Android to discover how Android is configured with a Proxy. You will need to 
bridge this gap.


Sponsored Links

Re: Android Emulator and Proxy

by Finch » Fri, 18 Mar 2011 21:41:58 GMT

 Try starting the emulator with "emulator .... -http-proxy 

This will make the emulator use the specified proxy "globally" and
will work fine for development and testing.
I'm not sure what happens if one of your users needs to use a proxy
later on. I'd guess there's a way to retrieve the proxy settings?

I do know that a proxy can be specicified in HttpClient. Wait, let me
google that for you:
HttpClient client = new HttpClient();
client.getHostConfiguration().setProxy(proxyHost, port);

I cannot tell you how to retrieve the connection's proxy settings in
Android, but luckily, that was not your question :-)


Re: Android Emulator and Proxy

by Nirmal Patel » Fri, 18 Mar 2011 22:52:00 GMT

 Yes, I am using Apache HttpClient. 

I do not understand what you mean when you say "bridge this gap"??

Do you mean:

I need to provide the proxy settings to HttpClient explicitly?? I am doing 
the same right now by 
      HttpHost httpproxy = new HttpHost("", 5865); // a proxy 
running on my machine
However, this proxy is only applicable for our dev environment. Whereas 
actual users when running the app on their mobiles will be having direct 
access to internet. I am not sure how do I strip these proxy code from my 

Or do you mean

there is a way to query Android to find the proxy settings configured on the 
APN and pass them to HttpClient? Personally, I haven't come across those 


Re: Android Emulator and Proxy

by Nirmal Patel » Fri, 18 Mar 2011 23:00:59 GMT

 I did try to start the emulator by specifying the command line option but 
neither of the following works for me...


With either above... I am unable to access internet in emulator browser...  


Other Threads

1. Static header in ListView

I have a ListView with several columns and I need a header row at the
very top that labels each of these columns that *does not* scroll with
the rest of the ListView. I am using addHeaderView right now, but I've
ran into 2 problems:

1) The header scrolls. I need it outside of scrolling so that it's
always "floating" on top.

2) Each column in the header isn't lining up with the columns in the
listview. I can make the header columns and data columns all line up
perfectly if they're all in one big TableLayout, but how would I get
the header to be outside of the scrollview yet also stay uniform and
inline with the data columns?



2. How is the camera view angle determined in getHorizontalViewAngle ()?

I'm curious how the camera view angle determined using

Is it predefined within the API, or is it provided by the hardware?




3. where the device "/dev/graphic/fb0" or "/dev/fb0" created in the kernel code?

4. Example gallery style view with fling, bounce, animation, etc

5. sh4 undefined reference to `__fpscr_values'

6. Bionic Libc compilation

7. Any standard "Available on Android Market" graphic?