예제 #1
0
  @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
  public void onResume() {
    addView(previewStrategy.getWidget());

    if (camera == null) {
      cameraId = getHost().getCameraId();

      if (cameraId >= 0) {
        try {
          camera = Camera.open(cameraId);

          if (getActivity().getRequestedOrientation()
              != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
            onOrientationChange.enable();
          }

          setCameraDisplayOrientation();

          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH
              && getHost() instanceof Camera.FaceDetectionListener) {
            camera.setFaceDetectionListener((Camera.FaceDetectionListener) getHost());
          }
        } catch (Exception e) {
          getHost().onCameraFail(FailureReason.UNKNOWN);
        }
      } else {
        getHost().onCameraFail(FailureReason.NO_CAMERAS_REPORTED);
      }
    }
  }
예제 #2
0
 public void lockToLandscape(boolean enable) {
   if (enable) {
     getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
     onOrientationChange.enable();
   } else {
     getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
     onOrientationChange.disable();
   }
 }