Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

android - Is there any way to store full size image returned from camera activity in internal memory?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...