Reputation: 9825
Im learning from Android's BluetoothChat sample app and noticed that they are using a Handler to send updates to the UI as seen here . I was wondering why they wouldn't prefer to use a callback/listener to send updates to UI?
Upvotes: 1
Views: 1574
Reputation: 127
For a Guess. Handler is a perfect async solution. just post message to the MessageQueue,Handler(UI Thread) will take message from it. It can reduce your module's complexity.
CallBacks is another solution,but complex according Handler to update UI.
Upvotes: 1
Reputation: 4620
My guess is because Handler posts messages on the Thread it was created on. If you were using callbacks, you would have to take care of calling runOnUiThread(Runnable) in order to perform any kind of UI changes.
Upvotes: 3