1

Location permission is directly going to isAnyPermissionPermanentlyDenied on Android 13. It is not asking permission to user. Even if I grant the permission in settings also, it is going to isAnyPermissionPermanentlyDenied.

 val permissions = ArrayList<String>()
        permissions.add(Manifest.permission.ACCESS_FINE_LOCATION)
        Dexter.withActivity(this).withPermissions(permissions)
            .withListener(object : MultiplePermissionsListener {
                override fun onPermissionsChecked(report: MultiplePermissionsReport) {
                    when {
                        report.areAllPermissionsGranted() -> {
                            checkAppUpdate()
                        }
                        report.isAnyPermissionPermanentlyDenied -> {
                            startActivity(
                                Intent(
                                    Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                                    Uri.parse("package:" + BuildConfig.APPLICATION_ID)
                                )
                            )
                        }
                        else -> {
                            checkPermission()
                        }
                    }

                }

                override fun onPermissionRationaleShouldBeShown(
                    permissions: List<PermissionRequest>,
                    token: PermissionToken
                ) {
                    token.continuePermissionRequest()
                }
            }).onSameThread().check()

3 Answers3

2

First ask for COARSE location permission.

And only when the user allowed that ask for FINE.

blackapps
  • 8,011
  • 2
  • 11
  • 25
1

At first, Dexter is not under active maintenance anymore and I would not recommend to use it when you work on Android 13. The new way is also way more straight forward

Example:

    private val permissionList = arrayOf(
        Manifest.permission.READ_CONTACTS,
        Manifest.permission.WRITE_CONTACTS,
        Manifest.permission.CALL_PHONE
    )

    private val activityResultLauncher =
        registerForActivityResult(RequestMultiplePermissions()) { permissions ->
            if (!permissions.values.contains(false)) {
//                contactsProvider.addMockContactList()
                permissionState.value = true
                Log.d(TAG, "activityResultLauncher")
            }
        }
    private fun checkPermissions() {
        val hasPermission = permissionList.all {
            checkSelfPermission(it) == PackageManager.PERMISSION_GRANTED
        }
        Log.d(TAG, "checkPermissions")
        if (!hasPermission) {
            activityResultLauncher.launch(permissionList)
        } else {
            getContactList()
            permissionState.value = true
        }
    }

And second, for getting location information you need two permissions: ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION. Since fine location depends on coarse location, it will get instantly revoked everytime.

Chris Pi
  • 536
  • 1
  • 5
  • 21
0

What worked for me was, another dependency was adding maxSdk version which in turn was denying the permissions without even showing up the dialog. What I would recommend you is to check your android manifest file in the bottom tab look for Merged Manifest and look at your uses permission. If you find any maxSdk use this at end of permission to remove it. for example I used: <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" tools:remove="android:maxSdkVersion" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:remove="android:maxSdkVersion" />

Anurag
  • 1
  • 1