Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is it possible to stop the handler while counting 6 seconds? That the toast does not appear For example, I want the handler not to work in 3 seconds and the toast not to appear, then go to the second activity in 3 seconds. Thanks for the help friends

final Handler h= new Handler();
    h.postDelayed(new Runnable(){
        @Override
        public void run() {
            Toast.makeText(Ab.this, "finish 6 seconds", Toast.LENGTH_SHORT).show();
        }
},6000);
question from:https://stackoverflow.com/questions/65946453/how-to-stop-handler-in-java

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
185 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use h.removeCallbacksAndMessages(null);.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...