Reputation: 1272
Consider following code :
ImageView v = (ImageView)findByViewId(R.id.picture);
// do something with v
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
startGame();
}
}, 1500);
After 1.5 seconds the method
startGame()
is executed.
If the user wants to skip this waiting time, he should be able to click on an image to call startGame()
immediately without calling startGame()
after 1.5seconds again.
Upvotes: 0
Views: 246
Reputation: 1367
In order to stop your handler you need to use the following method.
handler.removeCallbacksAndMessages(null);
Referring to : RemoveCallBacksAndMessages
Hope it helps.
Upvotes: 1