小编Car*_*gey的帖子

BitmapFactory.decodeFile();

在我的应用程序中,我有一个文件:

private File TEMP_PHOTO_FILE = new File(Environment.getExternalStorageDirectory(), "temp_photo.jpg");
Run Code Online (Sandbox Code Playgroud)

这是在我的班级中直接声明的,并且对于那里的所有方法都是可见的.

我想用这个:

Bitmap thePhoto = BitmapFactory.decodeFile(Uri.fromFile(TEMP_PHOTO_FILE).toString());
Run Code Online (Sandbox Code Playgroud)

Uri.fromFile(TEMP_PHOTO_FILE).toString()生成字符串:"file:///mnt/sdcard/temp_photo.jpg"

为什么这不起作用?似乎因为我们正在处理文件,所以应该有一些decodeFile()接受URI作为输入的方法.由于不一致,不允许这样做非常令人沮丧.

android image

5
推荐指数
1
解决办法
8539
查看次数

标签 统计

android ×1

image ×1