Android:Socket
lastmod 2018-08-17created 2016-12-126 edits
Android Socket Programming Howto.
Category
- Android:Example:SocketServer: sample example of creating a Socket Server and Socket Client on Android.
Troubleshooting
NetworkOnMainThreadException
- When android.os.NetworkOnMainThreadException occurs
- Fixing NetworkOnMainThreadException in Android ICS 1
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
- Android
- java.net.Socket: description of JAVA Socket programming.
Favorite site
- Android: server/client Socket communication
- Socket communication on Android
- TCP/IP communication on Android
- Android Socket example
- Server/client Socket communication 2