Camera.Preview Callback not generating Camera Frames
<p>I have created a customized System Service, and i want my service to capture Camera frames in the background without Preview. I have followed the steps in developer.android website and implemented the following code, but it is not generating any frames. Here is the code:</p>

<pre><code> public void startCapture() {

//Start The camera
int openCamera = 0;//default camera to be opened
mCamera = Camera.open(openCamera);
Camera.Parameters p = mCamera.getParameters();
setPreviewSize(p.getPreviewSize());//method to get Camera size
mCamera.getParameters().setPreviewFpsRange(1, 2);
try{
    Camera.PreviewCallback mPreviewCallback = new Camera.PreviewCallback()
    { 

    @Override

    public void onPreviewFrame(byte[] data, Camera camera) {

    //  public void cameraPreview(byte[] data, Camera camera) {

    // TODO Auto-generated method stub

    decodeYUV420SP(rgb, data, width, height);//method for processing the image  

    bitmap.setPixels(rgb, 0, width, 0, 0, width, height);  

    String newFolder = "/Pictures";

    String extStorageDirectory = Environment.getExternalStorageDirectory().toString();

    File myNewFolder = new File(extStorageDirectory + newFolder);

    if (!myNewFolder.exists())

        myNewFolder.mkdir();            



    File file = new File(path, "/Pictures/Frame-"+count+".jpg");

    boolean fileCreated = file.createNewFile();

    FileOutputStream out = new FileOutputStream(file);

    bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);

    out.flush();

    out.close();
    };

}catch (Exception e) 
 {

       e.printStackTrace();

 }
}
mCamera.setPreviewCallback(mPreviewCallback);
mCamera.startPreview();
}
</code></pre>

<p>I wanted the frames to be captured and Stored in the SD Card in the Mentioned path.but i am not getting it done. what am i doing wrong here. Need some Help! </p>

<p>Thanks to the Replier in Advance.</p>
