Category "coroutinescope"

How to access lifecycleScope of the host fragment from a custom view?

I need to use coroutines inside a custom view. After watching this talk, I believe my best option is to use lifecycleScope as the coroutine scope, so that it wi

Parallel processing values emitted by flow in Kotlin

Kotlin code runBlocking { flow { for (i in 0..4) { println("Emit $i") emit(i) }} .onEach { if (it%2 == 0) delay(20

Suspend function 'callGetApi' should be called only from a coroutine or another suspend function

I am calling suspended function from onCreate(...) override fun onCreate(savedInstanceState: Bundle?) { ... ... callGetApi() } and the suspended

CoroutineScope Questions

At the Coroutine Scope, Why is the last println() called first when the launch block is called first?

How to wait for khttp (kotlin) response in Android

I've been trying to use khttp to send an .jpg file in an android activity but haven't been able to make it work. fun sendImage(view: View) { try {