Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 应用程序在使用ImageDecoder#createSource(contentResolver,uri)时崩溃_Java_Android_Kotlin_Mobile - Fatal编程技术网

Java 应用程序在使用ImageDecoder#createSource(contentResolver,uri)时崩溃

Java 应用程序在使用ImageDecoder#createSource(contentResolver,uri)时崩溃,java,android,kotlin,mobile,Java,Android,Kotlin,Mobile,尝试替换用于从Uri检索图像的已弃用代码 MediaStore#图像#媒体#获取位图(contentResolver,uri) 用新的 ImageDecoder#createSource(contentResolver,uri) 这是我的新代码: Bitmap thumbNail; if (Build.VERSION.SDK_INT < 28) { thumbNail = MediaSt

尝试替换用于从Uri检索图像的已弃用代码

MediaStore#图像#媒体#获取位图(contentResolver,uri)

用新的

ImageDecoder#createSource(contentResolver,uri)

这是我的新代码:

Bitmap thumbNail;
                        if (Build.VERSION.SDK_INT < 28) {
                            thumbNail = MediaStore.Images.Media.getBitmap(
                                    getContentResolver(),
                                    data.getData()
                            );
                        } else {
                            ImageDecoder.Source source = ImageDecoder.createSource(getContentResolver(), data.getData());
                            thumbNail = ImageDecoder.decodeBitmap(source);
                        }
位图缩略图;
如果(Build.VERSION.SDK_INT<28){
缩略图=MediaStore.Images.Media.getBitmap(
getContentResolver(),
data.getData()
);
}否则{
ImageDecoder.Source=ImageDecoder.createSource(getContentResolver(),data.getData());
缩略图=图像解码器.解码位图(源);
}
但我注意到,每当我试图用它来处理一个大小相对较大的图像,大约2MB到3.5MB。应用程序崩溃了哪条消息

通道已无法恢复,将进行处理

我可能做错了什么,或者它不适合处理较大的图像文件?当我决定使用不推荐使用的方法时,应用程序工作正常:

MediaStore#图像#媒体#获取位图(contentResolver,uri)