views:

65

answers:

1

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.

+1  A: 

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.

CommonsWare