permissions-dispatcher / PermissionsDispatcher

A declarative API to handle Android runtime permissions.
https://github.com/permissions-dispatcher/PermissionsDispatcher
Apache License 2.0
11.21k stars 1.44k forks source link

Android 11 runtime permission authorization popup does not pop up #707

Open xie438305665 opened 3 years ago

xie438305665 commented 3 years ago

FAQs


Overview

Expected

Actual

Environment

Reproducible steps

hotchemi commented 3 years ago

Sorry we were focusing on maven central migration, would you mind elaborate on the issue?

misbahazmi commented 3 years ago

I am also facing the same issue i.e. Android 11 runtime permission authorization popup not coming. We updated the to version 4.8.0 also.

hotchemi commented 3 years ago

@misbahazmi are you using ktx or a normal one?

hotchemi commented 3 years ago

trying to repro the issue with sample and ktx-sample but haven't been able to 🤔

misbahazmi commented 3 years ago

@hotchemi - I am using normal one. I will try to reproduce the same. Thanks

hotchemi commented 3 years ago

any update here?

7RST1 commented 3 years ago

~I'm having the same issue. The location request does not appear on screen.~

hotchemi commented 3 years ago

Can anyone give us an example(wondering this is not the library-specific issue)? 👀

ininmm commented 3 years ago

@hotchemi not really sure whether others stuck in the same issue, but I am facing the similiar issue when I request the Location permissions(ACCESS_BACKGROUND_LOCATION).(I'm using ktx library.)

ininmm commented 3 years ago

Ok I think I've repro my issue in the ktx-sample project, just change COMPILE_SDK_VERSION and TARGET_SDK_VERSION to 30 then request all of the Location permissions, and I think this is because of the latest limit for Location background permission.

According to the doc, the system enforces us to request ACCESS_BACKGROUND_LOCATION after granted the foreground Locations, otherwise the request dialog will not appear.

I've granted the ACCESS_BACKGROUND_LOCATION successfully by 2-step requests:

    private lateinit var locationRequest: PermissionsRequester
    private lateinit var backgroundLocationRequest: PermissionsRequester

    override fun onAttach(context: Context?) {
        locationRequest = constructLocationPermissionRequest(
                LocationPermission.COARSE, LocationPermission.FINE,
                onShowRationale = ::onLocationShowRationale,
                onPermissionDenied = ::onLocationDenied,
                onNeverAskAgain = ::onLocationNeverAskAgain
        ) {
            backgroundLocationRequest.launch()
        }
        backgroundLocationRequest = constructLocationPermissionRequest(
                LocationPermission.BACKGROUND,
                onShowRationale = ::onLocationShowRationale,
                onPermissionDenied = ::onLocationDenied,
                onNeverAskAgain = ::onLocationNeverAskAgain
        ) {
            Toast.makeText(requireActivity(), "Enable location!", Toast.LENGTH_SHORT).show()
        }
    }

    // locationRequest.launch()
7RST1 commented 3 years ago

Turns out the dialog for the permissions didn't show up because I never requested them. My stupid ass thought the constructLocationPermissionRequest automatically added the location permissions for me, which I see now that it don't. Strike me from "having this issue" list.

bgervan commented 2 years ago

Is there any update or workaround for this? Blocks me to upgrade android version

hotchemi commented 2 years ago

oh sorry didn't notice the update, let us check

tayyabejaz commented 2 years ago

@hotchemi Is there any update or workaround?

hotchemi commented 2 years ago

Now considering what to do here. The quick workaround should be https://github.com/permissions-dispatcher/PermissionsDispatcher/issues/707#issuecomment-809973388 ?

hotchemi commented 2 years ago

Right now I'm thinking of creating one more pattern of PermissionRequestFragment and request the background permission, or having a lint to prevent the mistake from happening.