You should implement Camera.PreviewCallback instead of Camera.PictureCallback,
by using the interface implemented method:
public void onPreviewFrame(byte[] data, Camera camera) {
if (shutterEnabled){
shutterEnabled = false;
// Process data
// Put it on a Bitmap
// Send it to cropImage
// -----
}
}
Take in account that if you didn't set on your camera parameters, setPreviewFormat, the picture on viewPreviewFrame would arrive as YUV (NV21) format.
Actually I'm looking how to make this part, this is why I bumped into your question.
The point here, how are you going to pass the picture to the crop method, you should look into that.
The shutterEnabled flag, it's enabled from your listener that 'watches' for that event.
private void cropImage( picture){
Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.setDataAndType(picture, "image/*");
cropIntent.putExtra("aspectX",0);
cropIntent.putExtra("aspectY",0);
cropIntent.putExtra("return-data", true);
startActivityForResult(cropIntent, CAMERA_CROP_CODE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if (resultCode == RESULT_OK && requestCode == CAMERA_CROP_CODE){
Bitmap bmp = (Bitmap)data.getExtras().get("data");
}
}