Created
May 12, 2017 10:03
-
-
Save elizarov/0b3e3386d304478368b3eb0380b6f25a to your computer and use it in GitHub Desktop.
Perform some long-running initialization in background thread
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val application = this | |
launch(UI) { // start a new coroutine in Android UI context | |
// switch to background thread for some long-running initialization | |
run(CommonPool) { AndroidThreeTen.init(application) } | |
// then init UI | |
initUI() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment