Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Application stuck when requesting ACCESS_BACKGROUND_LOCATION #240

Closed
choryuidentify opened this issue Oct 15, 2019 · 4 comments
Closed

Application stuck when requesting ACCESS_BACKGROUND_LOCATION #240

choryuidentify opened this issue Oct 15, 2019 · 4 comments

Comments

@choryuidentify
Copy link

choryuidentify commented Oct 15, 2019

Expected behaviour

Show permission is granted or not granted

Actual behaviour

Stuck on there
tested on Android Q Emulator

Steps to reproduce

Permission -> Location -> Choose 'Allow only while using app'
then, write code

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
        Dexter.withActivity(this)
                .withPermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
                .withListener(object : PermissionListener{
                    override fun onPermissionRationaleShouldBeShown(permission: PermissionRequest?, token: PermissionToken?) {
                        Log.d("debug", "onPermissionRationaleShouldBeShown")
                    }

                    override fun onPermissionDenied(response: PermissionDeniedResponse?) {
                        Log.d("debug", "denied")
                    }

                    override fun onPermissionGranted(response: PermissionGrantedResponse?) {
                        Log.d("debug", "granted")
                    }
                }).check()
    }

and run, choose 'Keep while-in-use access' or 'Keep and don't ask again', It stuck.
If choose 'Allow all time', It stuck too but restart app, it will execute onPermissionGranted block

Version of the library

6.0.0

@choryuidentify choryuidentify changed the title Blocked when requesting ACCESS_BACKGROUND_LOCATION Application stuck when requesting ACCESS_BACKGROUND_LOCATION Oct 15, 2019
@AlexDundar
Copy link

I have the same problem. Is there any solution?

@pedrovgs
Copy link
Contributor

pedrovgs commented Nov 8, 2019

Hi @choryuidentify @AlexDundar I've been testing the issue you reported and it's not related to Dexter but the way you ask for the permission. When using the background location permission you have to request the fine location or coarse location permission too. However, your code is only requesting the background ones. If you use this code you'll see how the app is working now:

Dexter.withActivity(this)
            .withPermissions(Manifest.permission.ACCESS_BACKGROUND_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
            .withListener(object : MultiplePermissionsListener {
                override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
                    
                }

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

Remember to declare these permissions in the manifest.

Here you can find two useful resources related to this topic:

Screenshot 2019-11-08 at 12 49 46

Screenshot 2019-11-08 at 12 51 08

I hope this answers your question. I'm closing the issue for now. However, feel free to open it again if you think Dexter is not able to handle this permission properly.

@pedrovgs pedrovgs closed this as completed Nov 8, 2019
@dds861
Copy link

dds861 commented Jun 16, 2021

on api 30 it doesn't work.
created an issue, waiting for someone to comment ...

@PavelMostovoy
Copy link

it works on API 29, but doesn't work on API 30

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

No branches or pull requests

5 participants