有没有办法将相机活动返回的全尺寸图像存储在内存中?
我正在使用
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(externalFileObj));
意图来调用默认相机活动。要获得完整图像,您需要指定intent.putExtra()。但这始终需要仅适用于外部存储文件的 URI。
我尝试在内存中创建 temp.jpg 图像并传递其 URI
Uri.fromFile(new File(getFilesDir() + "/temp.jpg"));
,但在捕获图像后相机活动不会返回。
那么,在我们的活动中,没有办法在不使用任何外部存储的情况下从默认相机应用程序获取全尺寸图像吗?假设设备没有 SD 卡或当前正在使用,我无法避免使用它?
是的,我知道我们可以创建自己的相机预览界面,但我想使用默认的相机应用程序,因为它有更多选项是很自然的。
谢谢。
I am using
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(externalFileObj));
intent to call default camera activity. To get full image you need to specify intent.putExtra(). But this always requires URI that works only for external storage files.
I tried to create a temp.jpg image in internal memory and pass its URI
Uri.fromFile(new File(getFilesDir() + "/temp.jpg"));
but the camera activity won't return back after the image is captured.
So there is no way to get Full size image from default camera application in our activity without using any external storage ? Assuming that the device do not have SD card or currently in use is there no way I can avoid using it ?
Yes I know we can create our own camerapreview surface but I want to use the default camera application as it is natural with many more options.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
啊!我得到了它。默认情况下,内部存储器中的文件目录是私有的,外部应用程序不可写入(例如,相机应用程序是外部应用程序)
只需在应用程序空间(内部存储器)中以可写模式创建一个新目录,并将此 URI 传递给相机活动即可。一切都很好。根本不需要外部存储。经过测试并且工作正常。
Ah! I got it. Your files directory in internal memory is private by default and is not writable by external apps (e.g. Camera app is external app)
Just create a new directory in writable mode in your application space (internal memory) and pass this URI to the camera Activity. And everything works fine. No need of external storage to be present at all. Tested and works fine.
我刚刚使用了如下代码:
是否有某种原因它必须位于内部存储中?我预计只有像 HTC Incredible(具有内部照片存储)这样的手机才能在内部明确存储照片。
I have just used code like the following:
Is there some reason it has to be in internal storage? I'd expect that only phones like the HTC Incredible (which has internal photo storage) would be able to explicitly store photos on internal.