Catch more camera exceptions.

Some devices will simply fail to open the camera with a runtime
exception. In this case, all we can do is catch it and report the error.
This commit is contained in:
Greyson Parrelli 2018-10-19 15:57:34 -07:00
parent 8ec3cf6a43
commit 668e8dee5d

View File

@ -34,9 +34,20 @@ public class Camera1Controller {
if (Camera.getNumberOfCameras() <= 0) {
onCameraUnavailable();
return;
}
camera = Camera.open(cameraId);
try {
camera = Camera.open(cameraId);
} catch (Exception e) {
onCameraUnavailable();
return;
}
if (camera == null) {
onCameraUnavailable();
return;
}
Camera.Parameters params = camera.getParameters();
Camera.Size maxSize = getMaxSupportedPreviewSize(camera);