You can't pause nor stop android.os.Handler. You can add and remove callbacks or messages. To remove all callbacks and messages, call
handler.removeCallbacksAndMessages(null);
Question
Hello i wish to be able to stop my custom handler fully, basically to be able to reset it. Here is the code i have used to pause it. Can anyone please give me some hints/help. i would appreciate it. thanks
//fetching pause button id
pauseButton = (Button) findViewById(R.id.pauseButton);
pauseButton.setOnClickListener(new View.OnClickListener() {
//pause timer
public void onClick(View view) {
timeSwapBuff += timeInMilliseconds;
customHandler.removeCallbacks(updateTimerThread);
}
});
Solution
You can't pause nor stop android.os.Handler. You can add and remove callbacks or messages. To remove all callbacks and messages, call
handler.removeCallbacksAndMessages(null);