简体   繁体   English

如何获取Android相机捕获的最后一张图像的路径?

[英]How to get the path to the last image captured by Android camera?

I am using the built-in camera in my Android app and having problems getting the path to the last captured image. 我在Android应用中使用内置摄像头,但是无法获取最后拍摄的图像的路径。

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    ....
}

Intent data contains a thumbnail of the last captured image, not the actual image saved to the SD card. Intent data包含最后捕获的图​​像的缩略图,而不是保存到SD卡的实际图像。 So, how do I get the path to the actual full size image? 那么,如何获得实际全尺寸图像的路径?

Thanks in advance. 提前致谢。

This SO answer is probably what you are looking for: 这样的答案可能就是您想要的:

How to pick an image from gallery (SD Card) for my app? 如何从图库(SD卡)中为我的应用程序选择图像?

Alternatively, you could set the path for the picture manually before starting the Camera activity. 或者,您可以在开始“相机”活动之前手动设置图片的路径。 You could add this path like this: 您可以这样添加此路径:

cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(FILE_PATH));

Then on the result, you check if the resultCode is RESULT_OK, and use the path of the image you already know. 然后在结果上,检查resultCode是否为RESULT_OK,并使用您已经知道的图像的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM