In this, app I’ve made two activities. When we click on any item of the listView in MainActivity , we navigate to StateActivity.
I made a network call in MainActivity. But, when I’m making the same network call in StateActivity, I’m getting this error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.covid19_tracker, PID: 23294
java.lang.IllegalStateException: Already Executed
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:141)
at com.example.covid19_tracker.StateActivity$fetchResults$1$response$1.invokeSuspend(StateActivity.kt:69)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
How shall I execute the same network call twice?