Java 切换按钮状态取决于服务器的反馈
我想让Arduino服务器和android客户端的切换按钮状态取决于服务器的字符串反馈 我已经试过了,但不起作用 下面的代码在一周前很糟糕,我没有做任何更改,但现在我遇到了问题 阿杜伊诺: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
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();
应用程序崩溃了吗?张贴您的日志。不,不会,但收到反馈后切换按钮不会更改