Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants