How to detect if front camera is available in android?
Use this method to detect whether devices has a front camera or not.
private boolean hasFrontCamera() {
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
return true;
}
}
return false;
}