Java Code Examples for android.util.AndroidException

The following are top voted examples for showing how to use android.util.AndroidException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: AppRTC-Android   File: Camera2Enumerator.java   View source code 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 2
Project: AndroidRTC   File: Camera2Enumerator.java   View source code 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
Project: VideoCRE   File: Camera2Enumerator.java   View source code 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 4
Project: AppRTC-Android   File: Camera2Enumerator.java   View source code 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 5
Project: AppRTC-Android   File: Camera2Enumerator.java   View source code 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 6
Project: AndroidRTC   File: Camera2Enumerator.java   View source code 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 7
Project: AndroidRTC   File: Camera2Enumerator.java   View source code 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 8
Project: VideoCRE   File: Camera2Enumerator.java   View source code 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 9
Project: VideoCRE   File: Camera2Enumerator.java   View source code 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 10
Project: stresstest_android   File: AndroidExceptionCommand.java   View source code 4 votes vote down vote up
public AndroidExceptionCommand() {
    setName(AndroidException.class.getSimpleName());
}
 
Example 11
Project: stresstest_android   File: AndroidExceptionCommand.java   View source code 4 votes vote down vote up
@Override
public void execute() throws Exception {
    throw new AndroidException(name());
}
 
Example 12
Project: stresstest_android   File: ArrayIndexOutOfBoundsExceptionCommand.java   View source code 4 votes vote down vote up
public ArrayIndexOutOfBoundsExceptionCommand() {
    setName(AndroidException.class.getSimpleName());
}