我的源代码:
tvOut.setText("Connect...");
Log.d("my", "Connect...");
try {
InetAddress serverAddr = InetAddress.getByName("192.168.1.121");
Log.d("my", "InetAddress serverAddr...");
socket = new Socket(serverAddr, 3426);
Log.d("my", "socket = new Socket...");
...
logcat的:
12-11 00:16:36.605:D / my(1247):连接......
12-11 00:16:36.675:D / my(1247):InetAddress serverAddr ...
12-11 00:16:36.715:D / AndroidRuntime(1247):关闭虚拟机
哪里有错误?
答案 0 :(得分:0)
使用AsyncTask进行网络连接,并在AndroidManifest.xml中注意Internet权限