-1
私は1秒ごとにそのスイッチをチェックするスイッチとタイマーを持っています。Switch.setChecked()はコードをクラッシュさせます
protected void onCreate(Bundle savedInstanceState) {
switchOnOff = (Switch) findViewById(R.id.switchOnOff);
// more code...
m_timer = new Timer();
m_timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if(switchOnOff != null && switchOnOff.isChecked() && m_TcpClient != null) {
if (!m_TcpClient.IsSocketUp()) {
switchOnOff.setChecked(false); <---- the code crashes here
}
}
}
}, 0, 1000);
}
これらの条件がすべて当てはまる場合は、スイッチをオフにしたいが、アプリケーションがクラッシュする。
私は間違っていますか?
ありがとうございました。
アプリのクラッシュを言うたび、常にクラッシュログを投稿することを忘れないでください –