Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using runOnUiThread() inside thread to update User interface

Tags:

android

Can I use runOnUiThread() inside a thread to update the user interface while running the thread, or handler is more efficient ? .

like image 268
sunilkarkala Avatar asked Feb 12 '26 01:02

sunilkarkala


1 Answers

Yes you can use runOnUiThread() from a non UI thread to update the UI. That method uses a handler internally if you are not currently on the UI thread so using your own handler will not be more efficient. If you are already on the UI thread then the runnable will be executed immediately.

like image 121
George Mulligan Avatar answered Feb 13 '26 15:02

George Mulligan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!