I need to take a photo from phone camera to analyze it, but I do not need to show the content (image of camera) on SurfaceView. Can I use Camera class without SurfaceView holder? One way is to simply hide SurfaceView but Is there a way to not using it at all?
I tried like this but it throws an error: takePicture failed
onCreate:
mCamera = getCameraInstance(); //private Camera mCamera;
mCamera.startPreview();
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mCamera.takePicture(null, null, mPicture);
}
});
Camera:
public static Camera getCameraInstance() {
Camera c = null;
try {
c = Camera.open(); // attempt to get a Camera instance
} catch (Exception e) {
e.printStackTrace();
}
return c; // returns null if camera is unavailable
}
private Camera.PictureCallback mPicture = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
System.out.println("CLICK");
}
};