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.
That is the behavior of the
android.hardware.CameraAPI, theandroid.hardware.camera2API, and third-party libraries that simplify those APIs (e.g., Fotoapparat, CameraKit-Android).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 acontentUripointing to aContentProviderthat 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 acontentUriforEXTRA_OUTPUT(though they should).