If I have a Handler handler = new Handler()
and run a delayed task for it handler.postDelayed(xxx, xxx)
, is that possible to check has the postDelayed()
was called or not?
Runnable runnable = ( ) -> { System. out. println( "Running the runnable at " + Instant. now() ); }; ScheduledExecutorService scheduledExecutorService = Executors.
postDelayed(Runnable r, Object token, long delayMillis) Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses. final void. removeCallbacks(Runnable r)
A Handler allows communicating back with UI thread from other background thread . This is useful in android as android doesn't allow other threads to communicate directly with UI thread. A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue.
is that possible to check has the postDelayed() was called or not?
One quick fix, in method assign some boolean
variable to true and then just perform checking.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With