I'm new to Kotlin and the coroutines. However I want to use it to initialize the Android ThreeTen backport library which is a long running task. I'm using the Metalab Async/Await Library (co.metalab.asyncawait:asyncawait:1.0.0).
This is my code:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val application = this
async {
//non-blocking initialize ThreeTen
await { AndroidThreeTen.init(application) }
//initialize UI on UI thread which uses the ThreeTen library
initUI()
}
}
Now I have the problem that the library is not initialized when initializing the UI. From my understanding initUI
shouldn't be called before AndroidThreeTen.init
is called.