Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 切换按钮状态取决于服务器的反馈_Java_Android_Server - Fatal编程技术网

Java 切换按钮状态取决于服务器的反馈

Java 切换按钮状态取决于服务器的反馈,java,android,server,Java,Android,Server,我想让Arduino服务器和android客户端的切换按钮状态取决于服务器的字符串反馈 我已经试过了,但不起作用 下面的代码在一周前很糟糕,我没有做任何更改,但现在我遇到了问题 阿杜伊诺: if (packetBuffer[0]=='3') { if (buttonstate == HIGH) { Udp.beginPacket(Udp.remoteIP(),Udp.remotePort()); Udp.write("on"); U

我想让Arduino服务器和android客户端的切换按钮状态取决于服务器的字符串反馈

我已经试过了,但不起作用

下面的代码在一周前很糟糕,我没有做任何更改,但现在我遇到了问题

阿杜伊诺:

if (packetBuffer[0]=='3')
{
    if (buttonstate == HIGH)
    {
        Udp.beginPacket(Udp.remoteIP(),Udp.remotePort());
        Udp.write("on");
        Udp.endPacket();
    }
    else
    {

        Udp.beginPacket(Udp.remoteIP(),Udp.remotePort());
        Udp.write("off");
        Udp.endPacket();
    }

}
安卓:

coming = new String(recd.getData());

Toast.makeText(getApplicationContext(),coming,Toast.LENGTH_LONG).show();

textView = (TextView)findViewById(R.id.textView);
textView.setText(coming);

if (coming=="on")
{
    apf.setChecked(true);
}

else if (coming=="off")
{
    apf.setChecked(false);
}

d1.close();

应用程序崩溃了吗?张贴您的日志。不,不会,但收到反馈后切换按钮不会更改