question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult is not working properly

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

2reactions
ZhiqingDaicommented, Sep 5, 2016

@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.

1reaction
Owen-Hwcommented, Apr 10, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

anthonycr/Grant: Simplifying Android Permissions - GitHub
For this example, we pretend we have a method writeToStorage() that requires the WRITE_EXTERNAL_STORAGE permission to function: PermissionsManager.getInstance() ...
Read more >
com.anthonycr.grant.PermissionsManager ... - Tabnine
This method will request all the permissions declared in your application manifest * for the specified {@link PermissionsResultAction}.
Read more >
Android6.0权限管理之开源项目Grant - CSDN博客
前言. Android开发者应该都知道在Android6.0后添加了权限的动态管理,我以前也写过一片博客关于怎么处理权限的动态申请。
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found