简体   繁体   中英

Android app works fine on Emulator, but not on Device. Uses Internet Connection

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM