Category "kotlin-coroutines"

Cannot reassign variable inside observer viewmodel

So I created MVVM app in kotlin to fetch movies from TMDB api, using injections and coroutines. My problem is that I cannot copy the list of returned movies int

How do I upload image file to google drive from android

I'm having a issue uploading a file to Google Drive. W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Android/data/dev/files/backup/https:/i.pic

How Kotlin's coroutine is cancelled under the hood?

Suppose we have a CoroutineScope and we launched several coroutines from it via launch. Then we do CoroutineScope.cancel(). And then we need to wait until cance

Coroutines test with spek

i'm try to write test for my viewModel function with coroutines. When request is success -> the data is sent to LiveData. If the request fails -> it is re

Why does a Flow which return records from Room keep to emit data when I add onStart { }? Is it bugs of Room or Compose?

I query records and return them as Flow<List<RecordEntity>> with Room. I run code A, and get result A as I expected. I hope to display a Loading UI

Share a queue between the mainThread and a coroutine

I am new to the coroutine concept. I'm not very confident in the code I've written. Basically I have a queue of user events that I send to my server. Adding an

Kotlin Coroutines Unit Testing

Im trying to test this suspend function: suspend fun <T> getResult(call: suspend () -> Response<T>): Resource<T> { val response = call()

Using Coroutine for continuous data polling and dumping to UI

My existing Android code uses AsyncTask to continuously poll data from a virtual COM port and dumps data to UI thread by overriding the onProgressUpdate() funct

Collect Flows in Service

So, I'm trying to collect data from flows in my Foreground service (LifecycleService) in onCreate(), but after the first callback, it is not giving new data. Th

how to implement Coroutine async/await on BaseViewModel

I'm using Retrofit with Coroutine using this structure to hit the API requests in my app but at some screens I send multiple request and I want to only show dat

java.util.NoSuchElementException: Flow is empty

I'm trying to test this repository using a unit test with JUnit 4 class AppRepository @Inject constructor( private val networkHelper: NetworkHelper, pri

Multiple coroutine async calls performance / high delay issues

I am currently debugging a performance issue (see here) which I could reduce to a code snippet that uses multiple async{} calls in a coroutine. I am delaying by

Android generated signed APK crash with an error but it's work fine in debug mode

I have a code it's work fine in debug mode also generated signed APK will work fine if isMinifyEnabled=false but for generated signed APK when isMinifyEnabled=t

Confused about official Android documentation on Flow

I refer to the official Android documentation on using the Flow library in the recommended app architecture. In the UserRepository class: class UserRepository @

How to observe ContentProvider changes for coroutine flow

I have a flow to fetch data from database via content provider. fun getDataFlow(): Flow<Result> { return flow { emit(Result.Loading) // f

Room DB ANR Input dispatching timed out

I am doing a db get operation for my cart page which has multiple tables. I have mapper class which has all the relations with all the tables. I have used corou

How to change main scope to another in recyclerview, adapter?

This is my code in adapter using recyclerView. How to improve this code to not use Main Scope, but to use scope that could be disposal? I need to have access to

Using rememberCoroutineScope() vs LaunchedEffect

Context In Jetpack compose, we have the option of using rememberCoroutineScope() as well as using the LaunchedEffect composable in order to use coroutines / run

My MutableStateFlow doesnt emit when called from suspend function in test

I am trying to write tests for my Repository which provides access to my Room database. For this, I wrote a Mock Database and a mock DAO: My Database: abstract

Kotlin Flow - Some emitted events not received when collect

I am using MutableStateFlow. My flow type is sealed class with different states (Loading, Success, Error, etc). Initial value of my flow is empty: private val _