Capture Recording

When you create project in the portal, it comes with the default triggers of Shake and ScreenGrab, so the SDK captures a recording when your user shakes the device or takes a screenshot - actions considered as triggers. You can extend this capability by incorporating your own additional triggers by creating another in the portal which will then have an action type of Custom.

For instance, you might want to capture a recording when your user presses a button in your app or completes a specific sequence.

However you capture the recording, the SDK user interface will always appear to let your users review the footage, edit and submit.

Select a Trigger and Capture Recording

  1. Decide from what event you want to capture the video, for example a button press. We will call this the trigger. This very simple example shows a possible trigger - when onButtonClick is called inside a Jetpack Compose app.

    Kotlin
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    
        val flightRecorder = FlightRecorderSdk(
            this, 
            lifecycle, 
            this, 
            apiKey = "API_KEY"
        )
    
        setContent {
            AppTheme {
                Surface() {
                    MyScreen(onButtonClick = { 
                        // This will be the trigger
                    })
                }
            }
        }
    }
  2. Make sure you are capturing a reference to the output of FlightRecorderSdk when you initialize the SDK.

    Kotlin
    val flightRecorder = 
        FlightRecorderSdk(
            this, 
            lifecycle, 
            this, 
            apiKey = "API_KEY"
    )

    Java
    var flightRecorder = 
          this,
          getLifecycle(), 
          this, 
          "YOUR_API_KEY", 
          true, 
          false
    );

  3. Choose an approach to access the flightRecorder variable from the trigger in your code. You could choose create a class to hold flightRecorder and access it statically.

  4. Call triggerCaptureRecording at the moment you want to capture the video inside the trigger.

    Kotlin
    flightRecorder.triggerCaptureRecording()

    Java
    flightRecorder.triggerCaptureRecording();

    In our Kotlin Jetpack Compose example, we call the method from the onButtonClick function:

    Kotlin
        setContent {
            AppTheme {
                Surface() {
                    MyScreen(onButtonClick = { 
                        flightRecorder.triggerCaptureRecording() 
                    })
                }
            }
        }

Last updated