package androidclient.test;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class AndroidClient_Activity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
//System.out.println("Has requested");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_android_client_);
//System.out.println("Has requested");
try {
java.net.Socket sc = new Socket(InetAddress.getByName("192.168.1.100"),2024);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Has requested");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_android_client_, menu);
return true;
}
}
应用程序已运行到服务器。它在监视器中有输出。但是在我启动客户端后,它无法连接服务器。我还在 oncreate() 方法中添加了一些输入语句。它没有响应,也没有输出异常。
谁能给我一个指南?非常感谢!