aryaxt
aryaxt

Reputation: 77626

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.

Upvotes: 2

Views: 517

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007339

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.

Upvotes: 1

Related Questions