I would like to create a new thread in onCreate
and communicate with the UI thread using post
on a View
. However, the post
ed statements never seem to be run. Here's a small example:
import android.app.Activity
import android.os.Bundle
import android.widget.TextView
import kotlin.concurrent.*
import org.jetbrains.anko.*
class MainActivity: Activity(), AnkoLogger {
protected override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val view = TextView(this)
setContentView(view)
thread() {
info("before post")
view.post({ info("inside post") })
info("after post")
}
}
}
Looking at the log, I can only see before post
and after post
, but never inside post
.
What am I doing wrong?