Android, camera in my app is rotated
<p>i'm opening the Camera in my app and the cam display is rotated by 90deg allways even when i rotating the device in my hands.</p>

<p>the code:</p>

<pre><code>import java.io.IOException;
import java.util.List;    
import android.content.Context;
import android.hardware.Camera;
import android.view.Display;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.WindowManager;

public class CameraSurfaceView extends SurfaceView implements SurfaceHolder.Callback
{
        private SurfaceHolder holder;
        private Camera camera;
        private Context context;
        public CameraSurfaceView(Context context) 
        {
                super(context);

                //Initiate the Surface Holder properly
                this.holder = this.getHolder();
                this.holder.addCallback(this);
                this.holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
                this.context = context;
          }

        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int width,
                int height) {               

        // Now that the size is known, set up the camera parameters and  begin
            // the preview.
            Camera.Parameters parameters = camera.getParameters();
            List&lt;Camera.Size&gt; previewSizes = parameters.getSupportedPreviewSizes();
            Camera.Size size = previewSizes.get(0);
            parameters.setPreviewSize(size.width, size.height);           

            Display display = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();

            if(display.getOrientation() == Surface.ROTATION_0)
            {
                //parameters.setPreviewSize(height, width);                           
                parameters.setRotation(90);
            }

            if(display.getOrientation() == Surface.ROTATION_90)
            {
                //parameters.setPreviewSize(width, height);                           
            }

            if(display.getOrientation() == Surface.ROTATION_180)
            {
                //parameters.setPreviewSize(height, width);               
            }

            if(display.getOrientation() == Surface.ROTATION_270)
            {
                //parameters.setPreviewSize(width, height);
                parameters.setRotation(180);
            }                
            camera.setParameters(parameters);                
            camera.startPreview();              
        }    
        @Override
        public void surfaceCreated(SurfaceHolder holder) {
             try
             {
                     //Open the Camera in preview mode
                     this.camera = Camera.open();
                     this.camera.setPreviewDisplay(this.holder);
             }
             catch(IOException ioe)
             {
                     ioe.printStackTrace(System.out);
             }              
        }    
        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {
            // Surface will be destroyed when replaced with a new screen
            //Always make sure to release the Camera instance
            camera.stopPreview();
            camera.release();
            camera = null;              
        }
  }
</code></pre>

<p>Any ideas ? Thanks</p>

<p>p.s how do i know what is the correct choose for my device in the line</p>

<pre><code>List&lt;Camera.Size&gt; previewSizes = parameters.getSupportedPreviewSizes();
</code></pre>
