简体   繁体   English

使用SSH将Android设备连接到Raspberry Pi

[英]Connecting Android Device to Raspberry Pi using SSH

I am trying to connect to my Raspberry Pi using an android device. 我正在尝试使用Android设备连接到我的Raspberry Pi The application just shuts down without any force close error after i call the connect() method. 我调用connect()方法后,应用程序仅关闭而没有任何force close error I think my problem is session.connect(1000). 我认为我的问题是session.connect(1000)。 Thanks in advance. 提前致谢。

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();

      }
  }

Have you got the correct permissions in your Manifest.xml file for Network connectivity? 您在Manifest.xml文件中获得了用于网络连接的正确权限吗? I know this is a comment really. 我知道这确实是评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM