I recently noticed that the Camera API is deprecated and I found the new API called Camera2.
I have read the documentation but I don\'t really understand it.
So
I used the code from the Google Camera2 API sample with some changes to get the front and back cameras working including saving the images locally and changing the shape of the TextureView by using an overlay.
I dealt with image rotation using exif interface too.
There is quite a bit of code so I'm going to post a link to my GitHub repo:
https://github.com/craigspicer/Camera2API
https://nullparams.com/camera-2-api-tutorial/