Not working in Coroutine Scope
Nithinjith opened this issue · 4 comments
Description
The library is not working in coroutine scope
KPermissions version:
V3.2.1
API level:
30
Sample code:
private fun checkPermissionAndProceed() = lifecycleScope.launchWhenStarted {
val result = permissionsBuilder(CAMERA, MICROPHONE, STORAGE).build().sendSuspend()
if (result.allGranted()) {
joinChannel(binding.etChannel.text.toString())
}
}
Stack trace:
D/ResultLauncherRuntimePermissionHandler: requesting permissions: android.permission.CAMERA, android.permission-group.MICROPHONE, android.permission-group.STORAGE
2021-07-29 09:07:50.948 16593-16593/com.bolder.programbuilder I/Choreographer: Skipped 283 frames! The application may be doing too much work on its main thread.
I've tried your code with the version 3.2.1 of this library, but it works correctly.
Where are you invoking checkPermissionAndProceed()
? In my tries, I tried to invoke that in Activity.onCreate()
and it works.
I am calling it from the fragment. Is it not supported permission check from fragment?
In which Fragment method are you invoking checkPermissionAndProceed()
? I've tried to invoke that in Fragment.onCreate
, Fragment.onCreateView
and Fragment.onViewCreated
but it works correctly.
Closing this since there's no longer activity on it. Feel free to re-open it if necessary.