On the Internet, we can see that many basic tutorials use 127.0.0.1 as the IP address of the PC host when connecting the simulator to the PC host. In fact, this error occurs.If you use this address, it is like we usually use a PC to debug some WebProgramThe localhost is the same, but in the Android system, localhost points to the Android system. Therefore, when the address 127.0.0.1 is used for debugging, the host does not respond normally.According to my personal development experience, the correct IP address for PC host debugging on the android simulator should be: 10.0.2.2 Android 4.0 or above, which means the network cannot be connected in the main thread, and an error message will appear. Obtain the JSON data on the network in section 5.4 of the network programming book android4.0.CodeAndroid 4.0 and later versions cannot run, and listview cannot obtain data. After the program runs, the main interface is blank, and the program throws a network exception. Integer code = conn. getresponsecode (); all statements after this statement are not executed. This problem was discovered only after system. Out. println () was added. Think of the limit of 4.0. I used to know that the reason why I met myself was still half a day. The reading of this book has noticed that the above routine is correct on 2.3. Download routine code
Http://ishare.iask.sina.com.cn/f/33606153.html? From = DL