BitmapFactory.decodeFile(filePath, options) 返回 Null 6.0权限
来源:互联网 发布:网络的利大于弊 编辑:程序博客网 时间:2024/06/04 23:25
今天在做拍照上传的时候遇到个问题,根据路径获取Bitmap 失败,一直返回空,以为这个路径获取Bitmap代码久经考验,不怀疑它,找参数传入是否正确,初步怀疑是 filePath 没传进去,打印 filePath.
但是发现 filePath 有值,起了怪了,一步步Debug,发现每一步都是正确的,没有问题,但是一到最后 return BitmapFactory.decodeFile(filePath, options) ; 就为空,犹豫这个方法是 android的,所以也没法一步步点进去debug。
换一个转换bitmap 的方法,发现抛出异常,打印,权限被拒绝。
根据代码,知道这一步肯定是需要 Read 和 Write 的权限,首先,去注册清单里面找,却发现都在。
再次测试,代码中打印是否获取到权限, -1 ,无权限,这就奇怪了,难道注册权限没用?
可以看出返回值为 0 则表示有该权限,返回值为 -1 则表示没有该权限
这个时候想到了我们项目的适配, target 是 24 ,6.0是23, 而6.0 有个新特性就是动态权限,也就是说 write 和 read 的权限是要在代码中获取的。
阅读全文
1 0
- BitmapFactory.decodeFile(filePath, options) 返回 Null 6.0权限
- BitmapFactory.decodeFile返回NULL
- android BitmapFactory.decodeFile()返回为null问题
- BitMapFactory.decodeFile always returns null.
- BitmapFactory.decodeStream(inputStream,null,options)返回为null
- BitmapFactory.decodeFile
- BitmapFactory.decodeStream返回null
- BitmapFactory 方法:decodeFileDescriptor()、decodeFile()
- decodeFile解析正确的路径却返回null???
- BitmapFactory.Options
- BitmapFactory.Options
- BitmapFactory.Options
- BitmapFactory.Options
- BitmapFactory.Options
- BitmapFactory.Options
- BitmapFactory Options
- BitmapFactory.Options
- BitmapFactory.Options
- java 编程思想--I/O系统(二)
- 宽文之感悟 JDF2框架
- codeforces 628B New Skateboard
- APK Signature Scheme v2
- python 出现InsecurePlatformWarning: A true SSLContext object is not available错误
- BitmapFactory.decodeFile(filePath, options) 返回 Null 6.0权限
- libjpeg的ARM linux移植
- Kafka——使用spring进行集成
- CentOS7挂起再打开上不了网问题解决方案
- 新手必备代码片段整理
- codeforces 632C The Smallest String Concatenation 排序
- Activity如何缓存
- 性能数据不稳定因素
- Android工程的目录结构详解