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

PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult is not working properly #13

Open
Shajeel-Afzal opened this issue Jan 27, 2016 · 10 comments

Comments

@Shajeel-Afzal
Copy link

I am trying to do:

PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult(getActivity(),
                            new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, new PermissionsResultAction() {

                                @Override
                                public void onGranted() {
                                    Intent taskPicturesStarter = new Intent(getActivity(), TaskPicturesActivity.class);
                                    taskPicturesStarter.putExtra(ActivityHelper.KEY_TASK_MODEL, mTaskModel);
                                    startActivityForResult(taskPicturesStarter, DATE_TIME_PICKER_ACTIVITY_CODE);
                                }

                                @Override
                                public void onDenied(String permission) {
                                    Toast.makeText(getActivity(),
                                            "Sorry, we need the Storage Permission to do that",
                                            Toast.LENGTH_SHORT).show();
                                }
                            });

But onGranted or onDenied method are not executing.

In the fragment i have also included:


@Override
    public void onRequestPermissionsResult(int requestCode,
                                           @NonNull String[] permissions,
                                           @NonNull int[] grantResults) {
        PermissionsManager.getInstance().notifyPermissionsChange(permissions, grantResults);
    }

I have also tried reinstalling the app but still same problem.

@DarthWendigo
Copy link

Same issue here, the first time onGranted/onDenied never is called.

@andreabellitto
Copy link

For me onGranted/onDenied NEVER is called

@AnthonyDou
Copy link

The same issue here, pls fix it.

@Isabellle
Copy link

Isabellle commented Aug 9, 2016

Same here :( - OnGranted is called but not OnDenied

@andreabellitto
Copy link

We need a fix

@ZhiqingDai
Copy link

Same here !onGranted/onDenied never be called in Android 6.0. Can you fix it?

@ZhiqingDai
Copy link

@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions,
@NonNull int[] grantResults) {
PermissionsManager.getInstance().notifyPermissionsChange(permissions, grantResults);
}
I use this code ,and onGranted/onDenied can be called in my Activity.

@JarenFeng
Copy link

JarenFeng commented Mar 13, 2017

Same here.And I think I find the reason.
Here is some code in method PermissionsManager#notifyPermissionsChange(line 266 to 234 with v1.1.2)

for (int n = 0; n < size; n++) {
    Iterator<PermissionsResultAction> iterator = mPendingActions.iterator();
    while (iterator.hasNext()) {
        if (iterator.next().onResult(permissions[n], results[n])) {
            iterator.remove();
         }
         mPendingRequests.remove(permissions[n]);
     }
}

We can see that the "Callback" was removed only when first of the permissions's callback was called,so that any other permissions were not called when action done.

@JarenFeng
Copy link

@ZhiqingDai 你请求的permissions中的每个permission都能收到回调吗?

@Owen-Hw
Copy link

Owen-Hw commented Apr 10, 2017

需要在每一个请求权限(单个或所有)的地方都重写下面这个方法,才可以正确回调。
@OverRide
public void onRequestPermissionsResult(int requestCode,
@nonnull String[] permissions,
@nonnull int[] grantResults) {
PermissionsManager.getInstance().notifyPermissionsChange(permissions, grantResults);
}

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

8 participants