I am using an ACTION_IMAGE_CAPTURE Intent to take photos, which I then manipulate.
I want to save only the final image. How can I prevent photos from being saved immediately after photo is taken?
Your best bet is to copy the image returned in the result Intent and then use a ContentResolver to delete the original image. The different OEMs, of course, have different camera implementations. The procedure I described has worked with all of them from my testing.
This is assuming that there's some reason that you can't just manipulate the original image and write over it.
If you use a third-party app to take the picture for you:
The third-party app has to save the picture, because otherwise it cannot get the picture to you
The third-party app can do whatever else it wants, because it was written by somebody else, and they can do what they want
If that is unacceptable, do not use third-party apps to take the picture for you.
Related
Is it possible to take a picture and get the image as byte array without saving it?
All I want is, take an in memory picture. I don't want to save it. Also i plan to use other camera activity to take the picture (i mean, i don't want to implement my own camera logic)
Please note, I know that I can take a picture, read bytes and delete it. But I am looking if I can avoid this saving and deleting part, instead directly get the image in an in memory byte array.
Is it possible to take a picture and get the image as byte array without saving it?
That is the behavior of the android.hardware.Camera API, the android.hardware.camera2 API, and third-party libraries that simplify those APIs (e.g., Fotoapparat, CameraKit-Android).
i plan to use other camera activity to take the picture
If by "other camera activity", you mean a third-party camera app (e.g., via ACTION_IMAGE_CAPTURE), that will be difficult and unreliable. At best, you could try to use a content Uri pointing to a ContentProvider that you write that only holds onto written streams in memory. I would expect you to run out of heap space. Plus, not all camera apps will support a content Uri for EXTRA_OUTPUT (though they should).
I've seen that Android automatically generates a thumbnail when taking a photo, and saves it as an extra with the key "data". Is it possible to disable that action, as to save space in the device?
I've seen that Android automatically generates a thumbnail when taking a photo, and saves it as an extra with the key "data".
No, it does not. Camera apps may generate thumbnails and put them in a data extra in the Intent used with setResult(). Android, the operating system, does not.
Is it possible to disable that action, as to save space in the device?
I do not know what "space" you think you will "save". That thumbnail is held briefly in system RAM. It is not stored on disk.
If you are a programmer, and if you are writing an Android app, and if you are using an ACTION_IMAGE_CAPTURE Intent with startActivityForResult() to invoke a third-party camera app, then you can include EXTRA_OUTPUT to indicate where you want a full-sized image to be written. According to the ACTION_IMAGE_CAPTURE specification, the data extra is not needed in that case. Some camera apps will then skip that extra.
However, developers of third-party camera apps are welcome to do whatever they want. If they want to create the data extra on every ACTION_IMAGE_CAPTURE request, that is their decision to make, as they are the ones writing the camera apps.
I have an application that captures pictures by dispatching an intent. Upon return of control to the activity, I retrieve the intent, extract the data, transform it into a bitmap and use it in my application. Just some straight forward code.
The pictures taken are subject to some privacy obligations and my application takes care to delete all data. The problem is that all pictures taken by the Camera application seem to automatically be saves into internal storage. I was successful in deleting screenshots taken by the device and by clearing all thumbnails. What remains to be done is keep the Camera application from storing picture in the first place.
The problem as I see it is that I relinquish control to the application and, hence, cannot influence it in any way. I tried launching ACTION_IMAGE_CAPTURE_SECURE but that failed. I would much prefer the approach of keeping the application from storing the image to the approach of having to scan the internal storage location for images and delete them as I tried it and failed.
Note: I have assigned all the right permissions. Should you need code, I will be happy to post it but there is nothing that cannot be found already in other threads. If there is no solution to my preferred approach, how would I go about deleting all images located in the internal storage at DCIM\Camera? Thank you!
If you need to override that behavior, don't take the pictures via intent. Take them yourself, using the android.hardware.Camera API.
I have an application where i make use of the Camera API to specify my own settings and do some frame processing.
I need my application to take photos with the same settings the Android original Camera app does, but apparently I have no way to extract the procedures and intents from it. I have taken a look at the original Android Camera app class file, but it was not helpful, since it makes use of native routines for the parameters part...
Is there any way that I can obtain the parameters used by the original camera App? And in which way does it save the images?
I know that i can write to a File stream as suggested in many posts, and i have done so, but how can i actually save the specific information the device puts in the files, such as information on the camera, density, and such ?
Thanks in advance
I'm trying to use ACTION_IMAGE_CAPTURE to get an image from Camera. What places is safe to use as the EXTRA_OUTPUT ?
The only one I've found myself is SdCard, but it seems inconvenient to me (I need a permission, and user has to have an SdCard). Is there another place, I can use?
You could use Activity.getCacheDir().