Esempio n. 1
0
  public void switchCamera(Camera camera) {
    setCamera(camera);
    try {
      camera.setPreviewDisplay(mHolder);
    } catch (IOException exception) {
      Log.e(TAG, "IOException caused by setPreviewDisplay()", exception);
    }
    Camera.Parameters parameters = camera.getParameters();
    parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);
    requestLayout();

    camera.setParameters(parameters);
  }
Esempio n. 2
0
  // unregister
  @Override
  public void onPause() {
    super.onPause();
    sensorManager.unregisterListener(this);

    // camera
    // Because the Camera object is a shared resource, it's very
    // important to release it when the activity is paused.
    if (mCamera != null) {
      mPreview.setCamera(null);
      mCamera.release();
      mCamera = null;
    }
    // end camera
  }
Esempio n. 3
0
  // register to listen to sensors
  @Override
  public void onResume() {
    Log.e("onResume", " ");
    super.onResume();

    Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
    sensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_FASTEST);

    // sensorManager.registerListener(this, sensor);

    // camera
    // Open the default i.e. the first rear facing camera.
    mCamera = Camera.open();
    mCamera.setDisplayOrientation(90);

    // cameraCurrentlyLocked = defaultCameraId;
    mPreview.setCamera(mCamera);

    // end camera
  }