I'm doing a native Android app, using the device's cameras. After I start the first Activity, calling the camera (Back), I created a button, with the function of switching between the cameras (Front, Back).
I just have a little difficulty doing this. They take the camera that is being used and switch to another type (Front -> Back / Back -> Front). Could you help me solve this problem?
Code below - >
public void cameraFrontal(View view){
int numCamera = Camera.getNumberOfCameras();
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
if(numCamera < 0){
Log.i("Script", "Nenhuma câmera encontrada");
}else {
if(cameraManager.isOpen() == true && numCamera == 2){
Log.i("Script", "Camera --> " + cameraInfo.facing);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
Toast.makeText(this, "Chamada da Câmera Frontal", Toast.LENGTH_LONG).show();
}else if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
Toast.makeText(this, "Chamada da Câmera Traseira", Toast.LENGTH_LONG).show();
}
}
}
}