Photographic Memory
private void takePicture() {
camera.takePicture(null, null, photoCallback);
}
SurfaceHolder.Callback surfaceCallback=new SurfaceHolder.Callback() {
public void surfaceCreated(SurfaceHolder holder) {
camera=Camera.open();
try {
camera.setPreviewDisplay(previewHolder);
}
catch (Throwable t) {
Log.e("Photographer",
"Exception in setPreviewDisplay()", t);
Toast
.makeText(Photographer.this, t.getMessage(),
Toast.LENGTH_LONG)
.show();
}
}
public void surfaceChanged(SurfaceHolder holder,
int format, int width,
int height) {
Camera.Parameters parameters=camera.getParameters();
parameters.setPreviewSize(width, height);
parameters.setPictureFormat(PixelFormat.JPEG);
camera.setParameters(parameters);
camera.startPreview();
}
public void surfaceDestroyed(SurfaceHolder holder) {
camera.stopPreview();
camera.release();
camera=null;
}
};
Camera.PictureCallback photoCallback=new Camera.PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
// do something with the photo JPEG (data[]) here!
camera.startPreview();
}
};
}
Here, we initialize our SurfaceView in onCreate(). When the SurfaceView has
been created, we connect the camera to it. When the SurfaceView size has
been set (in surfaceChanged()), we configure the Camera to work with the