android.util.AndroidException Java Examples

The following examples show how to use android.util.AndroidException. 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 Project: webrtc_android   Author: ddssingsong   File: Camera2Enumerator.java    License: MIT License 6 votes vote down vote up
/**
 * Checks if API is supported and all cameras have better than legacy support.
 */
public static boolean isSupported(Context context) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    return false;
  }

  CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
  try {
    String[] cameraIds = cameraManager.getCameraIdList();
    for (String id : cameraIds) {
      CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(id);
      if (characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)
          == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
        return false;
      }
    }
  } catch (AndroidException e) {
    Logging.e(TAG, "Camera access exception: " + e);
    return false;
  }
  return true;
}
 
Example #2
Source Project: VideoCRE   Author: Piasy   File: Camera2Enumerator.java    License: MIT License 6 votes vote down vote up
/**
 * Checks if API is supported and all cameras have better than legacy support.
 */
public static boolean isSupported(Context context) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    return false;
  }

  CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
  try {
    String[] cameraIds = cameraManager.getCameraIdList();
    for (String id : cameraIds) {
      CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(id);
      if (characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)
          == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
        return false;
      }
    }
    // On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a
    // catch statement with an Exception from a newer API, even if the code is never executed.
    // https://code.google.com/p/android/issues/detail?id=209129
  } catch (/* CameraAccessException */ AndroidException e) {
    Logging.e(TAG, "Camera access exception: " + e);
    return false;
  }
  return true;
}
 
Example #3
Source Project: webrtc_android   Author: ddssingsong   File: Camera2Enumerator.java    License: MIT License 5 votes vote down vote up
@Override
public String[] getDeviceNames() {
  try {
    return cameraManager.getCameraIdList();
    // On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a
    // catch statement with an Exception from a newer API, even if the code is never executed.
    // https://code.google.com/p/android/issues/detail?id=209129
  } catch (/* CameraAccessException */ AndroidException e) {
    Logging.e(TAG, "Camera access exception: " + e);
    return new String[] {};
  }
}
 
Example #4
Source Project: webrtc_android   Author: ddssingsong   File: Camera2Enumerator.java    License: MIT License 5 votes vote down vote up
private   CameraCharacteristics getCameraCharacteristics(String deviceName) {
  try {
    return cameraManager.getCameraCharacteristics(deviceName);
    // On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a
    // catch statement with an Exception from a newer API, even if the code is never executed.
    // https://code.google.com/p/android/issues/detail?id=209129
  } catch (/* CameraAccessException */ AndroidException e) {
    Logging.e(TAG, "Camera access exception: " + e);
    return null;
  }
}
 
Example #5
Source Project: VideoCRE   Author: Piasy   File: Camera2Enumerator.java    License: MIT License 5 votes vote down vote up
@Override
public String[] getDeviceNames() {
  try {
    return cameraManager.getCameraIdList();
    // On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a
    // catch statement with an Exception from a newer API, even if the code is never executed.
    // https://code.google.com/p/android/issues/detail?id=209129
  } catch (/* CameraAccessException */ AndroidException e) {
    Logging.e(TAG, "Camera access exception: " + e);
    return new String[] {};
  }
}
 
Example #6
Source Project: VideoCRE   Author: Piasy   File: Camera2Enumerator.java    License: MIT License 5 votes vote down vote up
private CameraCharacteristics getCameraCharacteristics(String deviceName) {
  try {
    return cameraManager.getCameraCharacteristics(deviceName);
    // On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a
    // catch statement with an Exception from a newer API, even if the code is never executed.
    // https://code.google.com/p/android/issues/detail?id=209129
  } catch (/* CameraAccessException */ AndroidException e) {
    Logging.e(TAG, "Camera access exception: " + e);
    return null;
  }
}