tags:

views:

8

answers:

0

Hi Stackoverflw team

   I have a problem in implementing the code android camera. when i implements the code then it will run successfully but there is 1 problem here is that it captures multiple images as a waste images which shows nothing with 1 actual image i am using following code:-

preview = new Preview(this); ((FrameLayout) findViewById(R.id.preview)).addView(preview);

buttonClick = (Button) findViewById(R.id.buttonClick); buttonClick.setOnClickListener(new OnClickListener() { public void onClick(View v) { preview.camera.takePicture(shutterCallback,rawCallback,jpegCallback);
} }); Log.d(TAG, "onCreate'd"); }

ShutterCallback shutterCallback = new ShutterCallback() { public void onShutter() { Log.d(TAG, "onShutter'd"); } }; PictureCallback rawCallback = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { Log.d(TAG, "onPictureTaken - raw"); } };

PictureCallback jpegCallback = new PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) { FileOutputStream outStream = null; try { File file = new File(Environment.getExternalStorageDirectory()+"/images/"); file.mkdir(); String _path = "/sdcard/images/abc.jpeg"; outStream = new FileOutputStream(String.format(_path,System.currentTimeMillis())); outStream.write(data); outStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { }