【发布时间】:2014-02-10 17:26:13
【问题描述】:
我正在尝试使用安卓设备连接到我的Raspberry Pi。在我调用connect() 方法后,应用程序会在没有任何force close error 的情况下关闭。我认为我的问题是 session.connect(1000)。提前致谢。
public void Connect() {
JSch jsch = new JSch();
try {
jsch.setConfig("StrictHostKeyChecking", "no");
//open a new session
session = jsch.getSession(user, host, port); // pi, 192.168.43.213, 22
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword(password); //passwrord : raspberry
tv.setText("Connecting");
session.connect(1000); //connect session
tv.setText("Connected");
} catch (JSchException e) {
tv.setText("JSchException");
Toast t = Toast.makeText(ClientSSH.this, "Failed to Create Session or Timed Out", 1000);
t.setGravity(Gravity.CENTER, 0, 0);
t.show();
}
}
【问题讨论】: