Java Code Examples for android.hardware.camera2.CameraAccessException#CAMERA_ERROR
The following examples show how to use
android.hardware.camera2.CameraAccessException#CAMERA_ERROR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HdrViewfinderActivity.java From android-HdrViewfinder with Apache License 2.0 | 6 votes |
@SuppressLint("SwitchIntDef") @Override public String getErrorString(CameraAccessException e) { String errorMessage; switch (e.getReason()) { case CameraAccessException.CAMERA_DISABLED: errorMessage = getString(R.string.camera_disabled); break; case CameraAccessException.CAMERA_DISCONNECTED: errorMessage = getString(R.string.camera_disconnected); break; case CameraAccessException.CAMERA_ERROR: errorMessage = getString(R.string.camera_error); break; default: errorMessage = getString(R.string.camera_unknown, e.getReason()); break; } return errorMessage; }
Example 2
Source File: CameraDeviceImpl.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void checkIfCameraClosedOrInError() throws CameraAccessException { if (mRemoteDevice == null) { throw new IllegalStateException("CameraDevice was already closed"); } if (mInError) { throw new CameraAccessException(CameraAccessException.CAMERA_ERROR, "The camera device has encountered a serious error"); } }
Example 3
Source File: Camera2Controller.java From pixelvisualcorecamera with Apache License 2.0 | 5 votes |
/** Fetches the camera characteristics for the current camera. */ private boolean initCameraCharacteristics() { CameraManager manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); try { // Extract characteristics for the current camera. CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); activeArraySize = characteristics.get(SENSOR_INFO_ACTIVE_ARRAY_SIZE); maxDigitalZoom = characteristics.get(SCALER_AVAILABLE_MAX_DIGITAL_ZOOM); // Require a stream configuration map. Don't know why there wouldn't be one. StreamConfigurationMap map = characteristics.get( CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); if (map == null) { throw new CameraAccessException(CameraAccessException.CAMERA_ERROR); } int facing = characteristics.get(CameraCharacteristics.LENS_FACING); boolean lensFacingFront = (facing == CameraCharacteristics.LENS_FACING_FRONT); int sensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); outputOrientation = Orientation.getOutputOrientation( lensFacingFront, displayRotationCode, sensorOrientation); return true; } catch (CameraAccessException | NullPointerException e) { // NPE's can be thrown when unboxing some of the characteristics. This should never happen // on Pixel{1,2}. Log.w(TAG, "Failed to inspect camera characteristics", e); } return false; }