Java Client Socket Connection in Android
This question already has an answer here:
In your application the NetworkOnMainThreadException is occurred. From the doc you ca see that
The exception that is thrown when an application attempts to perform a networking operation on its main thread.
So you have to call your RunSocketClient method from another thread rather than the main thread. Use a handler or asynctask or different thread to perform this operation.
To know about good designing you can see this link
http://developer.android.com/training/articles/perf-anr.html
add these line to AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
Without these permission you cannot access network resources...
链接地址: http://www.djcxy.com/p/29538.html上一篇: Android中的HTTP响应