title: Rotation 180 degrees android doesn't work properly
body: <p>If I change left-side-base to right-side-base (both are landscape view modes for user) the application (activity) doesn't recreate. Hense, the camera is shown as horizontaly flipped image. The same result when I try to change position of my device for two portrait modes (normal and inverse). The device detects 90 degree rotation normaly. That is, left-side => portrait => right-size => inverse-portrait => left-side works correctly!</p>
  
  <p>Is it possible to fix this?</p>
  
  <p>I am using Android 4.4.4.</p>
  
  <p>Code:</p>
  
  <pre><code>    Display display = ((WindowManager)context.getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
  
      if(display.getRotation() == Surface.ROTATION_0){//0
  
          mCamera.setDisplayOrientation(90);
      }else if(display.getRotation() == Surface.ROTATION_90){//1
          mCamera.setDisplayOrientation(0);
      }else if(display.getRotation() == Surface.ROTATION_180){//2
          mCamera.setDisplayOrientation(270);
      }else if(display.getRotation() == Surface.ROTATION_270){//3
          mCamera.setDisplayOrientation(180);
      }
      Log.d(TAG, "ROTATION:" + display.getRotation() + " ");
  </code></pre>
  
  <p><strong>EDIT</strong>
  I mean, <code>onResume()</code> and <code>SurfaceCreate()</code> are never call when I rotate the device by 180 degs.</p>
  
  <p><strong>EDIT CODE OF FUNCTIONS</strong></p>
  
  <pre><code>SurfaceView sfv;
  FrameLayout fl0;
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //some code to initialize
      fl0 = (FrameLayout) findViewById(R.id.fl0);
      sfv = new SurfaceView(this);
      fl0.addView(sfv, 0);
      addSurfaceHolder();
  }
  private void addSurfaceHolder() {
      SurfaceHolder holder = sfv.getHolder();
  
      holder.addCallback(new SurfaceHolder.Callback() {
  
  
          @Override
          public void surfaceCreated(SurfaceHolder holder) {
              Log.d(TAG, TAG + " surfaceCreated");
              //this function never calls for 180 deg rotation.
              cameraStart(MainActivity.this, false);
              //some code for camera holder connection
          }
  
          @Override
          public void surfaceChanged(SurfaceHolder holder, int format,
              int width, int height) {
              Log.d(TAG, TAG + " surfaceChanged");
          }
  
          @Override
          public void surfaceDestroyed(SurfaceHolder holder) {
              ///Some code to destroy camera
              Log.d(TAG, TAG + " surfaceDestroyed");
          }
      });
  }
  @Override
  protected void onResume() {
      super.onResume();
      Log.d(TAG, TAG + " onResume"); //call for 90 deg rotation. not for 180 deg rotation.
  }
  
  public static void cameraStart(Context context, boolean startStopPreview) {
  
      if (mCamera == null) {
          mCamera = Camera.open(CAMERA_ID); //0
      }
  
      Camera.Parameters cameraParam = mCamera.getParameters();
  
      Camera.Size previewSize = cameraParam.getPreviewSize();
      previewFormat = cameraParam.getPreviewFormat();
      frameWidth = previewSize.width;
      frameHeight = previewSize.height;
      frameRect = new Rect(0, 0, frameWidth, frameHeight);
  
      Display display = ((WindowManager) context.getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
  
      if (display.getRotation() == Surface.ROTATION_0) { //0
  
          mCamera.setDisplayOrientation(90);
      } else if (display.getRotation() == Surface.ROTATION_90) { //1
  
          mCamera.setDisplayOrientation(0);
      } else if (display.getRotation() == Surface.ROTATION_180) { //2
  
          mCamera.setDisplayOrientation(270);
      } else if (display.getRotation() == Surface.ROTATION_270) { //3
  
          mCamera.setDisplayOrientation(180);
      }
      Log.d(TAG, "ROTATION:" + display.getRotation() + " "); //just calles for 90 deg rotation. not for 180 deg.
  }
  </code></pre>