tbruyelle/RxPermissions

Ask permission again

Closed this issue · 22 comments

Once the user denies permission, re-asking it doesn't show up the dialog to allow or deny.
I need to restart the application to make it appear again.

Is it by design? Or I'm missing something ?

RxPermissions.getInstance(context)
    .request(Manifest.permission.ACCESS_FINE_LOCATION)
    .subscribe(..)

No of course it's not by design ^^, it's a bug, probably duplicate with #42.

@jaydeep17 Sounds interesting. Could you please provide more detailed steps which you can reproduce it with? (Does not happen for me when using both request() and ensure()).

Deployed a new version 0.7.0 that should fix that. Please check.

I tried the new version, but it's still the same, it doesn't show up the second time

Can you post more code ? I need to understand where and when the library is invoked.

Here's a very simplified form of the calls to RxPermissions I have

RxPermissions.getInstance(this)
        .request(Manifest.permission.ACCESS_FINE_LOCATION)
        .flatMap(granted -> RxPermissions.getInstance(this)
            .request(Manifest.permission.ACCESS_FINE_LOCATION))
        .subscribe(...);

I don't have it exactly the same way as shown here, the second call to request is deep down in a sub function.

Why do you need a second call for the same permission ?

We have this utility class called RxGoogleMaps that carries out specific operations on Google Maps and every method inside that class that requires location permission asks for the permission before carrying out the operation. For example, showMyLocationButton(), moveToLastKnownLocation(), etc.
Unfortunately, once the permission is asked, then 2 levels deep we have a .flatMap(), that calls another of these RxGoogleMaps method, and thus permission is requested again.

I think you should request the permission only one time.

True that's a problem on my side, but don't you think RxPermissions should work, even if I request it twice.

Yes but it may be not possible since RxPermission had to deal first with configuration changes.

I have the same the question for that. If I want to deny this permission again. How can I get to change this permission?

If I want to deny this permission again

Its up to the user to grant or deny, you have no control on that.

I mean that when I request the permission again. If the user have granted the permission. the dialog(Permission) is not appear .How can I get the dialog appear again?
(English is not very well,please excuse me)

@BruceeWang

If the user have granted the permission. the dialog(Permission) is not appear .How can I get the dialog appear again?

After the user have granted the permission, the only way for user to revoke permission is via App Settings. Otherwise dialog won't appear again.

Yea, I actually think this is by design. After the dialog has appeared once, if the user granted or denied the permission, the permission, in theory should not appear again.


Edit:
I take that back. Unless they check never ask again, it should keep asking if they ever access whatever needs the permissions again.

Just to know if there is a way to trigger the dialog ot show again.

Yes, you can clear your data and that should allow you to receive the dialog again.

Any chance for that to be done programmatically? So that i cant ask
permission till that gets granted?

Il 09 set 2016 6:35 PM, "Ngoc Buu Tran" notifications@github.com ha
scritto:

Yes, you can clear your data and that should allow you to receive the
dialog again.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#44 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAMPS4DLhlYJ5li7VfLa9ekCPuSs4xBRks5qoYregaJpZM4H7EEm
.

toidv commented

Any update on this issue, I have the same issue here. Firstly, I request CAMERA permission (Manifest.permission.CAMERA). If a user grants the permissionI then request WRITE_EXTERNAL_STORAGE permission (Manifest.permission.WRITE_EXTERNAL_STORAGE). Depending on User grant/decline WRITE_EXTERNAL_STORAGE permission the captured Image will be located at ExternalStorageDirectory/ExternalFilesDir but the request for WRITE_EXTERNAL_STORAGE never get callback (onNext, onError, onComplete)

@toidv
can you post some code?

toidv commented

This is demonstration code @tarasantoshchuk
Firstly, request camera permission

private void requestCameraPermission() {
        mSubscription = rxPermissions.request(Manifest.permission.CAMERA)
                    .subscribe(new Subscriber<Boolean>() {
                        @Override
                        public void onCompleted() {
                        }

                        @Override
                        public void onError(Throwable e) {
                            e.printStackTrace();
                        }

                        @Override
                        public void onNext(Boolean aBoolean) {
                            if (aBoolean) {
                                 requestWriteExternalStoragePermission(MEDIA_TYPE_IMAGE.getMediaType());
                            } else {
                                InploiUtils.showSnackbar(view, R.string.permissions_not_granted);
                            }
                        }
                    });
    }

Then request write external storage permission

private void requestWriteExternalStoragePermission(final String mediaTpe) {
        if(mSubscription != null) {
            mSubscription.unsubscribe();
        }
        mSubscription = rxPermissions.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .subscribe(new Subscriber<Boolean>() {
                    @Override
                    public void onCompleted() {
                        Timber.e("onCompleted");
                    }

                    @Override
                    public void onError(Throwable e) {
                        Timber.e("onCompleted");
                        e.printStackTrace();
                    }

                    @Override
                    public void onNext(Boolean aBoolean) {
                        if (!aBoolean) {
                            showSnackbarWarning(aBoolean, mediaTpe);
                        } else {
                            showMediaType(aBoolean, mediaTpe);
                        }
                    }
                });
    }