现象:
测试Websocket server时出现如下error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.websocketserver, PID: 2201
java.lang.RuntimeException: Unable to start activity ComponentInfo{
com.example.websocketserver/com.example.websocketserver.MainActivity}: android.os.NetworkOnMainThreadException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler<