문제

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

        }
    });
도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top