Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

 

Show the video description

In this video we will learn, how to execute a piece of code by passing a Runnable to a Handler’s postDelayed method. We will also make this Runnable repeat itself and stop it on button click by calling removeCallbacks on our Handler.

activity_main.xmlMainActivity.java