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

Getting location permissions, any of them #339

Open
TWiStErRob opened this issue Dec 21, 2021 · 1 comment
Open

Getting location permissions, any of them #339

TWiStErRob opened this issue Dec 21, 2021 · 1 comment

Comments

@TWiStErRob
Copy link

Basic Information

Device type: emulator
OS version: 30
EasyPermissions version: 3.0.0

Describe the problem

I have an app that needs location, doesn't matter which permission. Since we have 2 of these, it's quite tricky, and didn't even start considering the background one.... The app works with coarse or fine, but has a better experience with fine.

If I pass this to requestPermissions with a rationale

private static final String[] LOCATION_PERMISSIONS = {
	Manifest.permission.ACCESS_FINE_LOCATION,
	Manifest.permission.ACCESS_COARSE_LOCATION
};

I get 2 permission dialogs (fine/coarse selector, and upgrade from coarse to fine) and the rationale dialog, if the user selects the coarse location to begin with. I think this is because EasyPermissions thinks that not all permissions were granted. Is there a way to solve this? I guess I need or instead of and relationship between items in the list?

@ahaapaka
Copy link

ahaapaka commented Jan 7, 2022

You can implement EasyPermissions.PermissionCallbacks and then accept either location permission in onPermissionGranted() callback.

    @Override
    public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
        if (perms.contains(Manifest.permission.ACCESS_COARSE_LOCATION) ||
                perms.contains(Manifest.permission.ACCESS_FINE_LOCATION)) {
            // App can access device's location
        }
    }

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