app/src/main/java/com/demo/selfqrcode/camera/CameraConfigurationManager.java
/**
   * Reads, one time, values from the camera that are needed by the app.
   */
Reads, one time, values from the camera that are needed by the app.
Reads one time values from the camera that are needed by the app .
void initFromCameraParameters(Camera camera) {
	camera.setDisplayOrientation(90);
    Camera.Parameters parameters = camera.getParameters();
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();
    if (width > height) {
      Log.i(TAG, "Display reports landscape orientation; assuming this is incorrect");
      int temp = width;
      width = height;
      height = temp;
    }
    screenResolution = new Point(width, height);
    Log.i(TAG, "Screen resolution: " + screenResolution);
    cameraResolution = findBestPreviewSizeValue(parameters, screenResolution);
    Log.i(TAG, "Camera resolution: " + cameraResolution);
  }
void initFromCameraParameters ( Camera camera ) { camera . setDisplayOrientation ( 90 ) ; Camera . Parameters parameters = camera . getParameters ( ) ; WindowManager manager = ( WindowManager ) context . getSystemService ( Context . WINDOW_SERVICE ) ; Display display = manager . getDefaultDisplay ( ) ; int width = display . getWidth ( ) ; int height = display . getHeight ( ) ; if ( width > height ) { Log . i ( TAG , "Display reports landscape orientation; assuming this is incorrect" ) ; int temp = width ; width = height ; height = temp ; } screenResolution = new Point ( width , height ) ; Log . i ( TAG , "Screen resolution: " + screenResolution ) ; cameraResolution = findBestPreviewSizeValue ( parameters , screenResolution ) ; Log . i ( TAG , "Camera resolution: " + cameraResolution ) ; }
Reads, one time, values from the camera that are needed by the app.
Reads one time values from the camera that are needed by the app .
// We're landscape-only, and have apparently seen issues with display thinking it's portrait  // when waking from sleep. If it's not landscape, assume it's mistaken and reverse them: