Android 4.0 main thread access network problems, android4.0
If the number of requests to access the network in the main thread is less than 4.0, ANR will be reported if the number of requests exceeds 6 S, which will lead to a problem. If the network is slow or the requested data is too large, the interface will be choppy, resulting in poor interface sensitivity. Therefore, network requests are generally not allowed in the main thread. google made adjustments at 4.0. Generally, when requesting the network in the main thread, an error will be reported, in this way, our programmers have to subscribe the thread to go to the network. If 4.0 is used to operate the network in the main thread, the following error message is returned:
<Span style = "color: # ff6666;"> 10-19 12:14:44. 656: E/AndroidRuntime (30444): Caused by: android. OS. NetworkOnMainThreadException </span>
Android Development Network Problems
When the main thread accesses the network, this error will be reported after Android 4.0. In fact, it is not recommended to access the network in the main thread, which will cause the interface to be not smooth. You should open another thread to access the network, after obtaining the data, return the result to the main thread.
For android webservice connection
I haven't tried either of them. It's easy for android to connect to web service. After android 4.0, the main thread will not allow access to the network. You can write a new thread to solve this problem.
Let's take a look at this example.
Www.cnblogs.com/..6.html