googlesamples / easypermissions

Simplify Android M system permissions
https://firebaseopensource.com/projects/googlesamples/easypermissions/
Apache License 2.0
9.87k stars 1.46k forks source link

Permissions are not requested, correctly anymore #263

Closed ItsReddi closed 6 years ago

ItsReddi commented 6 years ago

Basic Information

Device type: Galaxy S8 EasyPermissions version: 2.0.0 / 1.3.0

Describe the problem

What happened? What did you expect to happen? We discovered the same Problem as #255 after upgrading from compileSDK 26 to 27/28. (Permissions always return false, and no Dialog appears)

Because of that an our application is to big to get a good example i started a test with a fresh project. https://github.com/ItsReddi/permissiontest

In the above Project mostly anything is doing right. But the following problems i have found:

ItsReddi commented 6 years ago

if i go to appsettings and disable the permission Permission is not granted, requesting it is logged, but nothing happens

onRequestPermissionsResult is not called if permissions are disabled via appsettings and you trigger requestPermissions

samtstern commented 6 years ago

@ItsReddi thanks for providing the sample project! I was able to reproduce and fix your issue.

In your sample project you had this:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.v(TAG, "onActivityResult");
        permissions();
    }

But you need to add a line:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // ** ADD THIS LINE **
        super.onActivityResult(requestCode, resultCode, data);
        Log.v(TAG, "onActivityResult");
        permissions();
    }

In general you always want to call super when using onActivityResult or you can get strange behaviors.