'Android Studio CameraX Preview

I am following a tutorial on how to build a cameraX custom camera and i'm stuck.

In the tutorial he uses this:

        PreviewConfig previewConfig = new PreviewConfig.Builder().setTargetAspectRatioCustom(aspectRatio).build();
        Preview preview = new Preview(previewConfig)
        preview.setOnPreviewOutputUpdateListener() { 
            ...
        }

I found out that this method changed and now you don't need PreviewConfig so you can just do it like this:

        Preview preview = new Preview.Builder().setTargetAspectRatioCustom(aspectRatio).build();

But the setOnPreviewOutputUpdateListener() method does not exist anymore for Preview (Cannot resolve symbol 'setOnPreviewOutputUpdateListener'). How can i handle this?

Thank you very much.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source