how to save photos and videos with CameraKit

I’m making a camera app using Flurgle Camerakit, I have a camerapreview and all, I can call the cameraalistener, but what do I do after that?

the manual says to include the following in my onclick for the shutter button

cameraView.captureImage();

            cameraView.setCameraListener(new CameraListener() {
                @Override
                public void onPictureTaken(byte[] picture) {
                    super.onPictureTaken(picture);

                    Bitmap result = BitmapFactory.decodeByteArray(picture, 0, picture.length);
                    ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    result.compress(Bitmap.CompressFormat.PNG, 50, stream);
                    byte [] picArray = stream.toByteArray();


                }
            });

when i do so, my app freezes and crashes when i click the shutter button. i also cannot figure out how to save the picture that i took into anywhere on the phone.

the same goes for the video feature. they say to include:

cameraView.startRecordingVideo();

                    cameraView.setCameraListener(new CameraListener() {
                    @Override
                    public void onVideoTaken(File video) {
                        super.onVideoTaken(video);
                        // The File parameter is an MP4 file.
                    }
                });

                    cameraView.startRecordingVideo();
                    cameraView.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            cameraView.stopRecordingVideo();
                        }
                    }, 2500);

but when i do I get the same error as before, the app freezes and crashes.

can someone tell me how to save the created files onto the phone?

thanks in advance!

Edit 1: this is the logcat error when i press the video button. it turns out theres no error when i press the shutter button to take a picture, it just takes a really long time to convert the 13MP data from my phone into an array.

08-04 18:14:13.794 25959-26024/com.example.mayankthakur.myapplication E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f92bda9a0
08-04 18:16:42.314 25959-25959/com.example.mayankthakur.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                        Process: com.example.mayankthakur.myapplication, PID: 25959
                                                                                        java.lang.RuntimeException: unlock failed
                                                                                            at android.hardware.Camera.unlock(Native Method)
                                                                                            at com.flurgle.camerakit.Camera1.initMediaRecorder(Camera1.java:406)
                                                                                            at com.flurgle.camerakit.Camera1.startVideo(Camera1.java:233)
                                                                                            at com.flurgle.camerakit.CameraView.startRecordingVideo(CameraView.java:322)
                                                                                            at com.example.mayankthakur.myapplication.Activity2.onClick(Activity2.java:180)
                                                                                            at android.view.View.performClick(View.java:5269)
                                                                                            at android.view.View$PerformClick.run(View.java:21548)
                                                                                            at android.os.Handler.handleCallback(Handler.java:815)
                                                                                            at android.os.Handler.dispatchMessage(Handler.java:104)
                                                                                            at android.os.Looper.loop(Looper.java:207)
                                                                                            at android.app.ActivityThread.main(ActivityThread.java:5740)
                                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)

i would still like to know how i can save the picture i took, and how to save the video that i will take

Check this section of CameraKit

ckPermissions

strict lazy picture

strict

cameraView.setPermissions(CameraKit.Constants.PERMISSIONS_STRICT);

lazy

cameraView.setPermissions(CameraKit.Constants.PERMISSIONS_LAZY);

picture

cameraView.setPermissions(CameraKit.Constants.PERMISSIONS_PICTURE);