title: Android app camera preview stopped working (using deprecated `setType` method)
body: <p>I have a camera app that had a Camera Preview which worked.  The app was developed some years ago (2012) and i decided to reuse parts of its code, but, upon testing again (on same hardware i9100, different OS 4.4 vs 3.0), my camera preview image has a problem</p>
  
  <p><a href="https://i.stack.imgur.com/wrCdw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wrCdw.png" alt="enter image description here"></a></p>
  
  <p>when i move the phone, i see the image change and it responds to light and dark patterns (therefore app is communicating with camera).  </p>
  
  <p>this is my code (it uses deprecated method <code>setType</code>):</p>
  
  <pre><code>class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
  private static final String TAG = "TGCamera";
  
  SurfaceHolder mHolder;
  public Camera camera;
  public final String fileName = "/download/CameraGPS/zdelTempPhotoPreview.jpg";
  
  CameraPreview(Context context) {
      super(context);
      // Install a SurfaceHolder.Callback so we get notified when the
      // underlying surface is created and destroyed.
      mHolder = getHolder();
      mHolder.addCallback(this);
      mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
  }
  
  public void surfaceCreated(SurfaceHolder holder) {
      // The Surface has been created, acquire the camera and tell it where
      // to draw.
      camera = Camera.open();
      Parameters parameter02 = camera.getParameters();
      parameter02.setJpegThumbnailSize(80, 60);
      parameter02.setPictureSize(640, 480);
      camera.setParameters(parameter02);
      try {
          camera.setPreviewDisplay(holder);
          camera.setDisplayOrientation(90);
          Parameters parameters00 = camera.getParameters();
          //parameters00.setRotation(90);
          //parameters00.setFlashMode("on");
          //parameters00.setJpegQuality(20);
          camera.setParameters(parameters00);
  
          camera.setPreviewCallback(new PreviewCallback() {
  
              public void onPreviewFrame(byte[] data, Camera arg1) {
                  CameraPreview.this.invalidate();
              }
          });
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  
  public void surfaceDestroyed(SurfaceHolder holder) {
      // Surface will be destroyed when we return, so stop the preview.
      // Because the CameraDevice object is not a shared resource, it's very
      // important to release it when the activity is paused.
      camera.stopPreview();
      camera = null;
  }
  
  public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
      // Now that the size is known, set up the camera parameters and begin
      // the preview.
  
      //camera.getParameters().setRotation();
      //camera.getParameters().setJpegQuality(20);
      //camera.getParameters().setPictureSize(width, height)
  
      Parameters parameters = camera.getParameters();
      parameters.setPreviewSize(w, h);
      camera.setParameters(parameters);
      camera.startPreview();
  }
  
  @Override
  public void draw(Canvas canvas) {
      super.draw(canvas);
  
      Log.w(TAG,"clicked in preview");
      Paint p = new Paint(Color.RED);
      Log.d(TAG, "draw");
      canvas.drawText("PREVIEW", canvas.getWidth() / 2,
              canvas.getHeight() / 2, p);
  }
  </code></pre>
  
  <p>Any suggestions?</p>