GlobalScope.launch(Dispatchers.Main) { // Works with <http://Dispatchers.IO|Dispatchers.IO>
Timber.d("Current thread: ${Thread.currentThread().name}")
}
In debug, I can access
Dispatchers.Main
which is correctly plugged to the android handler.
Any idea what I'm doing wrong?
t
tseisel
05/03/2019, 11:23 AM
There should be nothing wrong with
Dispatchers.Main
on Android.
I'd advocate against using
GlobalScope
, as it doesn't account for structured concurrency. Try to launch your coroutine from the scope of an `Activity`/`Fragment`/`ViewModel`