我的回调函数中有一个线程,如下所示:
@Override
public void onConnectError(final BluetoothDevice device, String message) {
Log.d("TAG","Trying again in 3 sec.");
runOnUiThread(new Runnable() {
@Override
public void run() {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something
}
}, 2000);
}
});
}
当我按下后退按钮或 onDestroy 时,我将关闭上述线程。我该怎么做。谢谢
@Override
public void onBackPressed() {
// Close or distroy the thread
}
@Override
public void onDestroy() {
// Close or distroy the thread
}