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.Camera
API, theandroid.hardware.camera2
API, 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 acontent
Uri
pointing to aContentProvider
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 acontent
Uri
forEXTRA_OUTPUT
(though they should).