Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

onRequestPermissionsResult not called in non-activity class #343

Open
go-ammar opened this issue Jan 25, 2022 · 1 comment
Open

onRequestPermissionsResult not called in non-activity class #343

go-ammar opened this issue Jan 25, 2022 · 1 comment

Comments

@go-ammar
Copy link

Device type: Redmi note 8 pro
OS version: Android 11
EasyPermissions version: com.vmadalin:easypermissions-ktx:1.0.0_

I am making a helper class for EasyPermissions. The request dialog is being shown but the onRequestPermissionsResult is not being called inside the helper class. Its working fine if its inside an activity. Is there anyway in which onRequestPermissionsResult can be called from a non-activity class?

Code


   fun requestPermission(
        rationale: String,
        REQUEST_CODE: Int,
        permissions: String,
    ) {
        EasyPermissions.requestPermissions(
            mActivity,
            rationale,
            REQUEST_CODE,
            permissions
        )
    }

   override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<out String>,
        grantResults: IntArray
    ) {
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, mContext)
    }
@hiasel
Copy link

hiasel commented Feb 1, 2022

I can confirm this. Annotating a method with @AfterPermissionGranted that is not inside an Activity does not seem to trigger a callback and the function is not called after the permission dialog.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants