[英]Android - Camera intent not performing save, as mentioned in documentation
I have a camera intent set up to try to create a file in the root of my device. 我设置了摄像头,以尝试在设备的根目录中创建文件。
File storagePath = new File(Environment.getExternalStorageDirectory()+ "/Football_Fans");
storagePath.mkdirs();
File file = new File(storagePath, "FAN_IMAGE_TEMP");
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, storagePath);
startActivityForResult(cameraIntent,CAMERA_REQUEST_IMAGE);
When I run my application, I don't have any activityOnResult set, but I use fileExplorer to try to see if my file was created. 运行我的应用程序时,没有任何activityOnResult设置,但是我使用fileExplorer尝试查看是否创建了我的文件。 My folder gets created fine, but the photo does not show up.
我的文件夹创建得很好,但是照片没有显示。 Any idea why?
知道为什么吗?
The documentation states that if an EXTRA_OUTPUT
is set, it will write to that location. 文档指出,如果设置了
EXTRA_OUTPUT
,它将写入该位置。 So I'm confused why it's not working. 所以我很困惑为什么它不起作用。
The caller may pass an extra EXTRA_OUTPUT to control where this image will be written.
调用方可以传递一个额外的EXTRA_OUTPUT来控制该图像的写入位置。 If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field.
如果不存在EXTRA_OUTPUT,则会在Extra字段中将一个小型图像作为Bitmap对象返回。 This is useful for applications that only need a small image.
这对于只需要较小图像的应用程序很有用。 If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT.
如果存在EXTRA_OUTPUT,则将全尺寸图像写入EXTRA_OUTPUT的Uri值。
use Uri. 使用Uri。 try this
尝试这个
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(storagePath));
"..will be written to the Uri value of EXTRA_OUTPUT." “ ..将被写入EXTRA_OUTPUT的Uri值。”
You are passing in a File object (storagePath). 您正在传递一个File对象(storagePath)。 It expects a Uri so use this:
它期望一个Uri,所以使用这个:
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(storagePath));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.