https://kotlinlang.org logo
Title
h

Hieu Truong

04/26/2023, 5:00 AM
After device in idle state (app in background, app in foreground but screen locked) in amount of time, the app looks not recreated correctly. I put a refresh function in ViewModel that call some APIs which will be wrapped inside a Job. I always try to cancel old one before calling new Job. But it throws exception like this in logcat.
kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled; job=StandaloneCoroutine{Cancelling}@9d587f1
kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled; job=StandaloneCoroutine{Cancelling}@ffd197b
kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled; job=StandaloneCoroutine{Cancelling}@8d28a86
I tried to turn on
Do not keep activities
in Developer options and it recreated correctly, not like in idle state above. This is my first time posting here, if the question is not in a correct channel or need more information, please guide me. Any idea will help. Thanks.