In my project I make a custom camera, but I ran into a small problem, which in turn manifests itself only on Android 6 versions. Here is a method for getting an instance of a camera class that I call in the snippet:
private Camera getCameraInstance() { Camera camera = null; try { camera = Camera.open(); } catch (Exception e) { // cannot get camera or does not exist } return camera; } If you go into the body of the open() method, you will see the following code:
public static Camera open() { int numberOfCameras = getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { return new Camera(i); } } return null; } There are two cameras under debug. And return new Camera(i); is called return new Camera(i); , but in a fragment for some reason null returns that defies any explanation (at least for me). Once again, on the fourth and fifth versions, everything works correctly. The fact that googled - nothing helped.