有没有什么办法可以存储从摄像头的活动在内部存储器中返回原图?原图、有没有什么、在内部、摄像头

2023-09-13 00:47:12 作者:透过窗的阳光

我使用

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 ?

是的,我知道我们可以创建自己的相机preVIEW面,但我想使用默认的摄像头应用程序,因为它是自然拥有更多的选择。

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传递到相机的活动。 ,一切工作正常。无需外部存储将present的。经过测试,工作正常。

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.