【问题标题】:Send signal to av receiver with android使用 android 向 av 接收器发送信号
【发布时间】:2014-08-17 06:52:57
【问题描述】:

我想在我的 android 应用程序中实现一个功能来打开/关闭我的 av 接收器。 因此,我创建了一个套接字并通过 Telnet 向接收器发送命令,但没有任何反应。 Socket创建成功!

我的 AV 接收器是 Denon x-2000,根据官方协议,我必须发送 PWSTANDBY 命令。

 public void turnOff(View v){
    Runnable r = new Runnable() {

        @Override
        public void run() {
            Socket s = null;
            PrintWriter out = null;
            BufferedReader in= null;
            try{
                InetAddress ia = InetAddress.getByName("192.168.100.228");
                s= new Socket(ia, 23);
                out = new PrintWriter(s.getOutputStream(), true);
                in = new BufferedReader(new InputStreamReader(s.getInputStream()));
            } catch(IOException e){

            }
            Log.v("output","send standby");
            out.println("PWSTANDBY");
            out.flush();

            try {
                if(in.ready())
                Log.v("input", in.readLine());

            } catch (IOException e) {
                e.printStackTrace();
            }

            out.close();
            try {
                in.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                s.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    };

    Thread t = new Thread(r);
    t.start();


}

【问题讨论】:

    标签: java android sockets telnet


    【解决方案1】:

    好的,我自己找到了解决办法,我换行了

    out.println("PWSTANDBY");
    

    out.print("PWSTANDBY\r");
    

    它有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-04
      • 2014-05-08
      • 1970-01-01
      • 2014-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多