PermissionsManager.getInstance().requestPermissionsIfNecessaryForResult is not working properly
See original GitHub issueI 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:
- Created 8 years ago
- Reactions:1
- Comments:10
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.需要在每一个请求权限(单个或所有)的地方都重写下面这个方法,才可以正确回调。 @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { PermissionsManager.getInstance().notifyPermissionsChange(permissions, grantResults); }