Code example for Camera

Methods: setPreviewCallbackWithBuffer

0
	@Override 
	protected void lowLevelSetPreviewCallback(Camera camera, PreviewCallback cb) {
		if (cb != null) {
			Log.d("Setting optimized callback with buffer (Android >= 8). Remember to manage the pool of buffers!!!");
		} 
		camera.setPreviewCallbackWithBuffer(cb);
	} 
	 
	@Override 
	public void onPreviewStarted(Camera camera) {
		super.onPreviewStarted(camera);
 
		Size s = camera.getParameters().getPreviewSize();
		int wishedBufferSize = s.height * s.width * 3 / 2;
 
		camera.addCallbackBuffer(new byte[wishedBufferSize]);
		camera.addCallbackBuffer(new byte[wishedBufferSize]);
	} 
	 
	@Override 
	public void onPreviewFrame(byte[] data, Camera camera) {