Does a thread safe timer exist?
Is there another equivalent of Timer for android which is thread开发者_开发百科 safe? Using the timer causes problems in my application while updating the gui, most of the time it complains that gui is being updated from another thread, i tried using handlers but that didn't fix the problem.
Use postDelayed()
on any of your Views
. Have it do its work then call postDelayed()
again.
Or, use runOnUiThread()
instead of messing with your own Looper
/Handler
.
Or, create your Handler
as a private data member of the class with an ordinary initializer -- it would appear you are trying to create it in the background thread, which will not work.
精彩评论