请求权限调不起来,Can request only one set of permissions at a time
来源:互联网 发布:软件模块接口 规范 编辑:程序博客网 时间:2024/05/21 06:53
前天遇到个奇怪的问题,也不奇怪。
就是在扫码界面请求拍照权限,请求权限弹窗始终不会出来。
一路debug进去,发现是activity类下的
public final void requestPermissions(@NonNull String[] permissions, int requestCode) { if (mHasCurrentPermissionsRequest) { Log.w(TAG, "Can reqeust only one set of permissions at a time"); // Dispatch the callback with empty arrays which means a cancellation. onRequestPermissionsResult(requestCode, new String[0], new int[0]); return; } Intent intent = getPackageManager().buildRequestPermissionsIntent(permissions); startActivityForResult(REQUEST_PERMISSIONS_WHO_PREFIX, intent, requestCode, null); mHasCurrentPermissionsRequest = true;}此方法里的mHasCurrentPermissionsRequest为true,log显示也是 Can request only one set of permissions at a time。一次只能请求一组权限。
问题是我就单单请求了一个拍照权限,没有同时多次请求
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, PERMISSION_CAMERA_CODE); }}无奈,只好各种调试,发现在其他界面是可以正常调起来,总结下就是requestPermissions方法的第一个参数有问题。
但是看了半天activity类,还是没看懂mHasCurrentPermissionsRequest这个变量是怎么就被赋值为true了。
求哪位大神阅读这块的源码可以给个正确的解释,跪谢!!!
阅读全文
0 0
- 请求权限调不起来,Can request only one set of permissions at a time
- Error: "Database 'XXX' is already open and can only have one user at a time"
- ios error:A view can only be associated with at most one view controller at a time
- iOS使用XIB文件报错:reason: 'A view can only be associated with at most one view controller at a time!
- 【BCB】ocidl.h E2337 Only one of a set of overloaded functions can be ”C“ 报错解决办法
- Run Time中请求系统权限Requesting Permissions at Run Time
- vss 2005 提示 Only one database connection at a time is supported的处理
- svn报错can only be performed on a version resource [at this time].
- CHECKOUT can only be performed on a version resource [at this time].
- svn报错can only be performed on a version resource [at this time].
- The method onCreate in type MainActivity can only set one of public / protec
- 135 Which three statements are true about windows? (Choose three.) A. Only one window can be open at
- 155 Which three statements are true about windows? (Choose three.) A. Only one window can be open at
- Requesting Permissions at Run Time
- Requesting Permissions at Run Time
- [Python]Processing a String One Character at a Time
- Recipe 1.1. Processing a String One Character at a Time
- Android6.0如何在运行期间申请权限Requesting Permissions at Run Time
- [NOIP2015普及组]求和
- 3.PlayerController Move
- Mac下定时执行python脚本&sh脚本
- Content-Type
- Linux 常用命令
- 请求权限调不起来,Can request only one set of permissions at a time
- vue基础知识
- 交换机 路由器 防火墙asa 安全访问、配置 方式
- eclipse部署maven项目
- 各主流浏览器(PC、移动端)USERAGENT属性信息
- 老生常谈--java中到底是按值传递还是按引用传递
- IDEA 好用的插件
- 收藏下一些CSS样式JS特效网站
- ant一些总结