0

I am calling REST API from my android application using HTTP URL Connection, but i am always getting socket timeout exception when i am running app in emulator. I am getting the response when the API is accessed in browser. Also when i am running my app on mobile device i am getting response over mobile data. Is there any settings while accessing API's on emulator (any kind of proxy settings)

I have tried the below code but still getting socket timeout exception.

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("hostname", port number));
HttpURLConnection conn = (HttpURLConnection) url.openConnection(proxy);

Please Help.

Hardik Parmar
  • 712
  • 2
  • 13
  • 28
  • make sure in your emulator, you are able to access internet. – aquib May 10 '16 at 09:53
  • Actually i checked that as well. i am not able to access internet on emulaor . So this can be the issue?? If yes, what i am supposed to do? – Ajinkya Pote May 10 '16 at 09:55
  • check this link. May be it would be helpful.http://stackoverflow.com/questions/2039964/how-to-connect-android-emulator-to-the-internet – aquib May 10 '16 at 09:58
  • But i am getting response on emulator when i am connected to data card but don't get response when connected to the Ethernet connection. So, **No internet access** to the emulator can't be the problem i guess. – Ajinkya Pote May 11 '16 at 05:46

0 Answers0