I want to stop the handler in onDestroy(). The code as follows. blink() method call on for particular reason in activity but want to stop their service in to the destroy method.
final Handler handler = new Handler();
private void blink() {
PrintLog.log("On", "Blink Thread");
new Thread(new Runnable() {
@Override
public void run() {
int timeToBlink = 1000; //in milissegunds
try {
Thread.sleep(timeToBlink);
} catch (Exception e) {
}
handler.post(new Runnable() {
@Override
public void run() {
if (text_ATMCardInstruction.getVisibility() == View.VISIBLE) {
text_ATMCardInstruction.setVisibility(View.INVISIBLE);
} else {
text_ATMCardInstruction.setVisibility(View.VISIBLE);
}
blink();
}
});
}
}).start();
}
@Override
protected void onDestroy() {
// what is code here?
PrintLog.log("Stop", "serviceStop");
super.onDestroy();
}