Android Equivalent Of Settimeout And Cleartimeout Of Javascript?
There's an answer for setTimeout https://stackoverflow.com/a/18381353/433570 It doesn't provide info whether we can cancel the timer as we could in javascript. Is there a timer tha
Solution 1:
According to the documentation of Handler
public final void removeCallbacks (Runnable r)
Added in API level 1
Remove any pending posts of Runnable r that are in the message queue.
Example code:
Runnablerunnable=newRunnable() {
publicvoidrun() {
Log.i("Tag", "Runnable running!");
}
};
Handlerhandler=newandroid.os.Handler();
handler.postDelayed(runnable, 1000);
handler.removeCallbacks(runnable);
Post a Comment for "Android Equivalent Of Settimeout And Cleartimeout Of Javascript?"