问题描述:

I have an activity which tries to connect to an URL and downloads a JSON file.

This activity works perfect at the Emulator, but Constantly fails at the Device.

I used to get Connection timed out error, after some search on the net, I increased the timeout duration. But Now I get UnknownHost error.

The same URL works fine in the Browser on the device.

I tried every kind of program available in the internet which used http Connection to access/download something, everything end up work fine at the emulator. But fails at the device.

The Internet connection is fine in my device as the sample webkit programs are working fine.

I also enabled Internet permission for my app.

I also tried HttpPost & HttpGet methods.

I also tried running the connection in separate thread.

I get http response code as 200 in the Emulator and empty one in the device.

Is there something I am missing while using http connections in the device ?

here is a simple sample to try :

http://p-xr.com/android-tutorial-how-to-parse-read-json-data-into-a-android-listview/

Thx in advance

网友答案:

you can try to turn off your firewall. I did it and it worked for me. Hope this will help you.

相关阅读:
Top