Pulse FlightRecorder Docs
  • SDK Documentation
    • Pulse Labs FlightRecorder Documentation
      • iOS
        • Overview
        • Install the SDK
        • Get your API Key
        • SDK Configuration
          • Swift + SwiftUI
          • Swift + UIKit with Scenes
          • Swift + UIKit without Scenes
          • Objective-C with Scenes
          • Objective-C without Scenes
        • Create Custom Triggers
          • Capture Recording
          • Show the Introduction Screen
        • Update the SDK
        • Troubleshooting
      • Android
        • Overview
        • Install the SDK
        • Get your API Key
        • SDK Configuration
          • Kotlin
          • Java
        • Create Custom Triggers
          • Capture Recording
          • Show the Introduction Screen
        • Update the SDK
        • Troubleshooting
      • ReactNative
        • Install SDK for ReactNative iOS
        • Install SDK for ReactNative Android
        • Update the SDK
      • Flutter
        • Overview
        • Install the SDK
        • Get your API Key
        • SDK Configuration
        • Create Custom Triggers
          • Capture Recording
          • Show the Introduction Screen
      • In-app Surveys
        • Create Survey
        • Edit Survey
        • Launch Survey
        • Pause Survey
        • Survey Responses
        • Survey Styling
    • ⬅️FlightRecorder Home
Powered by GitBook
On this page
  1. SDK Documentation
  2. Pulse Labs FlightRecorder Documentation
  3. Android
  4. Create Custom Triggers

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() 
                    })
                }
            }
        }
PreviousCreate Custom TriggersNextShow the Introduction Screen

Last updated 1 month ago