# android

Erfannj En

07/04/2023, 2:43 PM
#coroutines #android Hello everyone I was developing my own app when I realized that when we immediately cancel the coroutine that is responsible for the collection of a StateFlow before the start of the operation, it is no longer possible to repeat the collect operation and the program process must be terminated and then the program execute it to give us the expected behavior, is this behavior correct for the scenario that I have implemented, i.e. we have two Fragments, the first one provides only one button, after which permission is granted from the user's side to the next Fragment, which is responsible for displaying the preview The camera is running. In this case, I go to App Settings and cancel the permission related to the camera. I return to the program and because I specified in the onStart method that if the permission of the camera was not granted, it will perform the popStack operation. I am surprised to see when I click on the grant button and go to the next page, the value of StateFlow is not collected


07/05/2023, 4:20 AM
What scope are you canceling? Activity.lifecycleScope or Fragment.viewLifecycleScope? Or you own coroutineScope instance? Include some code to make it easier for others. Also, this channel is not for that type of Android sdk question. My advice is open a stack overflow question and just place the link with a brief description. Otherwise, it will get tagged as "not kotlin"