socket异常
package com.example.bxsystem;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.UnknownHostException;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class LoginActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Button LoginBtn=(Button)findViewById(R.id.LoginBtn);
LoginBtn.setOnClickListener(LoginClick);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.login, menu);
return true;
}
private android.view.View.OnClickListener LoginClick=new Button.OnClickListener()
{
public void onClick(View v) {
/*Communicater CR= new Communicater();
NetData RecvData=new NetData();
String SQLText="select ID,DTYPE,DEPTNAME from DepartmentInfo where DTYPE='W' order by ID";
try {
CR.GetDbData(SQLText, RecvData);
} catch (IOException e) {
e.printStackTrace();
}*/
Socket TcpSocket=new Socket();
SocketAddress SvrAddr =new InetSocketAddress("192.168.1.100",9534);
try {
TcpSocket.connect(SvrAddr, 5000);
} catch (IOException e) {
e.printStackTrace();
}
}
};
}
真机一执行到TcpSocket.connect(SvrAddr, 5000);暂停几秒,然后黑屏,一会弹出“XXXXXX 已停止”对话框