Skip to content
Search

Android:Socket

lastmod 2018-08-17created 2016-12-126 edits

Android Socket Programming Howto.

Category

Troubleshooting

NetworkOnMainThreadException

Up to previous versions, handling network work on the UI thread did not raise any error. Of course, if the network was in poor condition, the main thread would block and the application would look frozen, so it was not commonly done. But it is true that some applications just handled network work on the main thread and hurt usability. It seems that from Android 4.0 on, such factors affecting usability are blocked in advance. So how do you fix this problem?? Simple. Write it with AsyncTask or Thread so that it does not affect the UI thread. Even if it is a little tedious, it is much better to implement network work so it runs on a separate thread, so it might not be bad to take this opportunity to get into the habit of using AsyncTask.

See also

Favorite site

References


  1. Android_ics_NetworkOnMainThreadException_troubleshooting.pdf ↩

  2. Android_server_client_socket_to_communicate.pdf ↩