I am making an custom camera application, so camera is open in activity view, but I don't know how to save captured image on sdcard?
I have used flowing code to open camera in activity view captured photo:
public class Camera_preview extends Activity implements SurfaceHolder.Callback,Camera.PictureCallback, OnClickListener {
Camera camera;
SurfaceView cameraView;
SurfaceHolder surfaceHolder;
Button Photo_btn;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.camera_layout);
Photo_btn =(Button)findViewById(R.id.camera_btn);
cameraView = (SurfaceView) this.findViewById(R.id.CameraView);
surfaceHolder = cameraView.getHolder();
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
surfaceHolder.addCallback(this);
actionBar.hide();
Photo_btn.setOnClickListener(this);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
}
@Override
public void surfaceCreated(SurfaceHolder holder)
{
// TODO Auto-generated method stub
camera =Camera.open();
try
{
camera.setPreviewDisplay(holder);
}
catch (IOException exception)
{
camera.release();
}
camera.startPreview();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
camera.stopPreview();
camera.release();
}
@Override
public void onPictureTaken(byte[] data, Camera camera) {
// TODO Auto-generated method stub
System.out.println("******data*********"+data);
camera.startPreview();
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v == Photo_btn)
{
camera.takePicture(null, null, this);
}
}
}
Please help.