title: Android Camera setDisplayOrientation does not work
body: <p>i am working camera project in android.my problem is camera <code>setDisplayOrientation</code> method is not working and my camera preview on surface always landscape.i want to expected portrait camera preview on SurfaceView. I am using Samsung galaxy y (Android 2.3.5) and my activity code shown below:</p>
  
  <pre><code>import java.io.IOException;
  
  import android.app.Activity;
  import android.graphics.PixelFormat;
  import android.hardware.Camera;
  import android.os.Bundle;
  import android.view.SurfaceHolder;
  import android.view.SurfaceView;
  import android.view.View;
  import android.widget.Button;
  
  public class AndroidCamera extends Activity implements SurfaceHolder.Callback{
  
   Camera camera;
   SurfaceView surfaceView;
   SurfaceHolder surfaceHolder;
   boolean previewing = false;;
  
   String stringPath = "/sdcard/samplevideo.3gp";
  
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
  
         Button buttonStartCameraPreview = (Button)findViewById(R.id.startcamerapreview);
         Button buttonStopCameraPreview = (Button)findViewById(R.id.stopcamerapreview);
  
         getWindow().setFormat(PixelFormat.UNKNOWN);
         surfaceView = (SurfaceView)findViewById(R.id.surfaceview);
         surfaceHolder = surfaceView.getHolder();
         surfaceHolder.addCallback(this);
         surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  
         buttonStartCameraPreview.setOnClickListener(new Button.OnClickListener(){
  
     @Override
     public void onClick(View v) {
      // TODO Auto-generated method stub
      if(!previewing){
       camera = Camera.open();
       if (camera != null){
        try {
         camera.setDisplayOrientation(90);
         camera.setPreviewDisplay(surfaceHolder);
         camera.startPreview();
         previewing = true;
        } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
        }
       }
      }
     }});
  
         buttonStopCameraPreview.setOnClickListener(new Button.OnClickListener(){
  
     @Override
     public void onClick(View v) {
      // TODO Auto-generated method stub
      if(camera != null &amp;&amp; previewing){
       camera.stopPreview();
       camera.release();
       camera = null;
  
       previewing = false;
      }
     }});
  
     }
  
  
  
   @Override
   public void surfaceChanged(SurfaceHolder holder, int format, int width,
     int height) {
    // TODO Auto-generated method stub
  
   }
  
   @Override
   public void surfaceCreated(SurfaceHolder holder) {
    // TODO Auto-generated method stub
  
   }
  
   @Override
   public void surfaceDestroyed(SurfaceHolder holder) {
    // TODO Auto-generated method stub
  
   }
  }
  </code></pre>
  
  <p>my problem shown blow figure:</p>
  
  <p><img src="https://i.stack.imgur.com/wChns.png" alt="enter image description here"></p>
  
  <p>Any one can help with any code or tutorial links and thanks for spending valuable your time </p>