0

I need to update views in activity every 1-2 seconds with data that i must get from the other thread. How can i do that ? I was reading about broadcast receiving, but i can`t imagine how to do that in my case. Can you ,please , give me some example with it, hope with comments ) Thanks, P.S. Sorry for clumsy english.

Trimod
  • 114
  • 1
  • 5
  • 3
    Use [AysncTask](http://stackoverflow.com/a/7618705/593709), which is called painless threading.. :p – Adil Soomro Feb 19 '12 at 10:22
  • thank you. It really is what i was looking for. This link helped me http://developer.android.com/resources/articles/painless-threading.html – Trimod Feb 19 '12 at 15:10

1 Answers1

1

You can pass a handler object from the activity to the thread. Once the work in the thread is over you can message the activity with the handler object. In the activity, you can update the UI as soon as the message is received. For more info on handlers refer http://developer.android.com/reference/android/os/Handler.html

user936414
  • 7,574
  • 3
  • 30
  • 29