有没有办法将从相机活动返回的全尺寸图像存储在内部存储器中? [英] Is there any way to store full size image returned from camera activity in internal memory?

查看:19
本文介绍了有没有办法将从相机活动返回的全尺寸图像存储在内部存储器中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(externalFileObj));

意图调用默认相机活动.要获得完整图像,您需要指定 intent.putExtra().但这始终需要仅适用于外部存储文件的 URI.

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.

我试图在内存中创建一个 temp.jpg 图像并传递它的 URI

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.

所以在我们的活动中,如果不使用任何外部存储,就无法从默认相机应用程序中获取全尺寸图像?假设设备没有 SD 卡或当前正在使用是没有办法的我可以避免使用它吗?

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.

谢谢.

推荐答案

啊!我知道了.默认情况下,您在内存中的文件目录是私有的,外部应用程序不可写(例如,相机应用程序是外部应用程序)

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)

只需在您的应用程序空间(内部存储器)中以可写模式创建一个新目录,并将此 URI 传递给相机 Activity.一切正常.根本不需要外部存储.经过测试,工作正常.

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.

这篇关于有没有办法将从相机活动返回的全尺寸图像存储在内部存储器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆