florent37 / RuntimePermission

Simpliest way to ask runtime permissions on Android, no need to extend class or override permissionResult method, choose your way : Kotlin / Coroutines / RxJava / Java7 / Java8
https://florent37.github.io/RuntimePermission/
Apache License 2.0
865 stars 70 forks source link

Java 7: No matter the selection, askPermission falls in the onDenied block #3

Closed MalcolmMcFly closed 6 years ago

MalcolmMcFly commented 6 years ago

I have a pretty basic Java 7 implementation. No matter what the user selects, I am always falling in the onDenied block:


        Toast.makeText(this, "photo button pressed", Toast.LENGTH_SHORT).show();
        askPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE)
                .ask(new PermissionListener() {
                    @Override
                    public void onAccepted(RuntimePermission runtimePermission, List<String> accepted) {
                        Toast.makeText(DetailActivity.this, "permission accepted", Toast.LENGTH_SHORT).show();
                    }

                    @Override
                    public void onDenied(RuntimePermission runtimePermission, List<String> denied, List<String> foreverDenied) {
                        // permission denied
                        Timber.d("permissions denied");
                        Toast.makeText(DetailActivity.this, "permission denied", Toast.LENGTH_SHORT).show();
                    }
                });
    }
florent37 commented 6 years ago

did you added them into your manifest ?

2018-03-20 13:10 GMT+01:00 Malcolm McFly notifications@github.com:

I have a pretty basic Java 7 implementation. No matter what the user selects, I am always falling in the onDenied block:

    Toast.makeText(this, "photo button pressed", Toast.LENGTH_SHORT).show();
    askPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE)
            .ask(new PermissionListener() {
                @Override
                public void onAccepted(RuntimePermission runtimePermission, List<String> accepted) {
                    Toast.makeText(DetailActivity.this, "permission accepted", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onDenied(RuntimePermission runtimePermission, List<String> denied, List<String> foreverDenied) {
                    // permission denied
                    Timber.d("permissions denied");
                    Toast.makeText(DetailActivity.this, "permission denied", Toast.LENGTH_SHORT).show();
                }
            });
}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/florent37/RuntimePermission/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfQXHP0jop9YtJSCx2OcgS6dWuO78Brks5tgPGjgaJpZM4Sxxyy .

MalcolmMcFly commented 6 years ago

Yes I did:


...
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <application
...
florent37 commented 6 years ago

I just made an update, can you test with 1.0.1 ?

MalcolmMcFly commented 6 years ago

@florent37 same result. Maybe I am doing something wrong. I'm using this in an AppCompatActivity, Android 7.0

florent37 commented 6 years ago

your code seems good, I try it

florent37 commented 6 years ago

I'm going into onAccepted with your code

MalcolmMcFly commented 6 years ago

@florent37 perhaps it is this particular device. I will try a few other devices, if that doesn't work I will create a gist.

florent37 commented 6 years ago

yes thanks

2018-03-20 15:54 GMT+01:00 Malcolm McFly notifications@github.com:

@florent37 https://github.com/florent37 perhaps it is this particular device. I will try a few other devices, if that doesn't work I will create a gist.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/florent37/RuntimePermission/issues/3#issuecomment-374627445, or mute the thread https://github.com/notifications/unsubscribe-auth/AFfQXDBd0zYzjjKUNLizNo-0HRr95DFMks5tgRgKgaJpZM4Sxxyy .

florent37 commented 6 years ago

can you try to uninstall & reinstall (with clear) the app, to see if you have not "never ask again"