一旦应用程序停止从服务器接收文本说它现在已断开连接,我需要它来拥有它我需要设置按钮以表示它已断开连接,这就是我现在所拥有的(这是在一个 while 循环中,我只是没有发布所有代码)
Thread.sleep(10);
counter++;
if (counter >= 100)
{
Log.d("ClientActivity","send S");
counter = 0;
out.println("S");
A2MCString = in.readLine();
Log.d("ClientActivity","got " + A2MCString);
if (A2MCString == null)
{
connected = false;
Log.d("ClientActivity","Closed1");
Connect.setText("Connect");
Log.d("ClientActivity","Closed2");
Connect.setBackgroundResource(R.drawable.contect_button);
Log.d("ClientActivity","Closed3");
DeBug.setText("Disconnected from " + serverIpAddress);
Log.d("ClientActivity","Closed4");
}
当我尝试将连接设置为“连接”时应用程序崩溃 logCat 错误是“android.view.ViewRoot$CalledFromWrongThreadException”如果你能帮助我,那就太好了!