Q:

Naming the capturing image third time

I created a basic service to get images from a camera every 10 second.  The service works perfectly, but I'm trying to name the image files like ImageYYYYddmm_HHmmSS.  After the second file, the images are getting the same YYYYddmm_HHmmSS, thus overwriting the first image.  Where is my mistake? 
public class CP extends Service
{
    Camera. PictureCallback mCall = new Camera. PictureCallback()
  {

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

         FileOutputStream outStream = null;
                try{

                    outStream = new FileOutputStream("/sdcard/Image"+tar+".jpg");
                    outStream.write(data);  outStream.close();

                    Log.i("CAM", data.length + " byte written: /sdcard/Image"+tar+".jpg");
                    camClose(sHolder);               

                 } catch (FileNotFoundException e){
                    Log.d("CAM", e.getMessage());
                } catch (IOException e){
                    Log.d("CAM", e.getMessage());
                }

     }
  };

    @Override
    public IBinder onBind(Intent intent) {

          return null;
    }

    public void camClose(SurfaceHolder sHolder) {

        if (null == mCamera)
            return;
        mCamera.stopPreview();
        mCamera.release();
        mCamera = null;
        Log.i("CAM", " closed");
        }
}

A:

Tar is never updating to the current time.   In your onPictureTaken, try something like this:
public void onPictureTaken(final byte[] data, Camera camera)
 {

     FileOutputStream outStream = null;
            try{

                Calendar cal = Calendar.getInstance();
                tar = (sdf.format(cal.getTime()));
                outStream = new FileOutputStream("/sdcard/Image"+tar+".jpg");
                outStream.write(data);  outStream.close();

                Log.i("CAM", data.length + " byte written: /sdcard/Image"+tar+".jpg");
                camClose(sHolder);               

             } catch (FileNotFoundException e){
                Log.d("CAM", e.getMessage());
            } catch (IOException e){
                Log.d("CAM", e.getMessage());
            }

 }

