Front camera save code
<p><strong>//can anyone tell me what is wrong with this code//</strong> 
  // ive been trying to get the front camera activated to take a picture without a preview when this activity gets called. the problem is that i i have not been able to get the image to save on the sdcard. can anyone tell me whats wrong with this code?//
         package com.dom;</p>

<pre><code>        import java.io.File;
        import java.io.FileNotFoundException;
        import java.io.FileOutputStream;
        import java.io.IOException;
        import android.app.Activity;
        import android.content.Context;
        import android.hardware.Camera;
        import android.hardware.Camera.PictureCallback;
        import android.os.Bundle;
        import android.util.Log;
        import android.view.SurfaceView;

        public class DummyActivity extends Activity {
            /** Called when the activity is first created. */
            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
            }
            public int cameraCount;
        public void takePictureNoPreview(Context context) throws IOException{
</code></pre>

<p>// open back facing camera by default//</p>

<pre><code>            Camera mycam=Camera.open();

            if(mycam!=null){
              try{
                  Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
                  cameraCount = Camera.getNumberOfCameras();
                  for ( int camIdx = 0; camIdx &lt; cameraCount; camIdx++ ) {
                    Camera.getCameraInfo( camIdx, cameraInfo );
                    if ( cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT  ) {
                        try {
                            mycam = Camera.open( camIdx );
                        } catch (RuntimeException e) {
                            String TAG = null;
                        Log.e(TAG, "Camera failed to open: " + e.getLocalizedMessage());
                        }}
                SurfaceView dummy=new SurfaceView(context);
                mycam.setPreviewDisplay(dummy.getHolder());    
                mycam.startPreview(); 

                mycam.takePicture(null, null,jpegCallback);
              }
                  }finally{
                mycam.release();
              }      

            }else{
              //booo, failed!
            }
        }

                PictureCallback jpegCallback = new PictureCallback() {
                    public void onPictureTaken(byte[] data, Camera camera) {
                        FileOutputStream outStream = null;
                         String TAG = null;
                        try {
</code></pre>

<p>//save came</p>

<pre><code>                            outStream = new FileOutputStream(String.format("/sdcard/%d.jpg", System.currentTimeMillis()));  
                            outStream.write(data);
                            outStream.close();
                            Log.d(TAG, "onPictureTaken - wrote bytes: " + data.length);
                        } catch (FileNotFoundException e) {
                            e.printStackTrace();
                        } catch (IOException e) {
                            e.printStackTrace();
                        } finally {
                        }

                        Log.d(TAG, "onPictureTaken - jpeg");
                    }
                };
              }
</code></pre>
