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);

        }
    });
Was it helpful?

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top