Handler or Launching a Coroutine Job to do something in the MainThread

Viewed 183

I've been wondering about whether it is a better approach to use a Handler (Looper.getMainLooper()) or launch a new Coroutine Job to do small things on the Main Thread, like updating a View.

Handler:

val uiHandler = Handler(Looper.getMainLooper())

fun foo() {
    uiHandler.post { 
        someView.update()
    }
}

Coroutine

fun foo() {
    lifecycleScope.launch {
        someView.update()
    }
}

I really don't know and couldn't find anything related on the Internet, but I'd love to acquire that knowledge.

0 Answers
Related