Common use cases
Here are some common use cases for testing foreground and background transitions:- Pressing the “home” button while the app is running (clears backstack)
- Deep linking into another app (backstack doesn’t wipe)
- Pressing a dedicated app launch button
- Pressing the Alexa voice button (overlays on top of the app)
Lifecycle manager and app framework
The Vega Lifecycle Manager (LCM) component in a Vega device is responsible for handling movement of the apps to the foreground or background. LCM works based on call from Fire TV home launcher. You can learn more about LCM in App Management and Communication Tools.Simulate transition between background and foreground
Let’s explore different mechanisms you can use to simulate foreground and background transitions of your apps.Home launcher sends app to the background
This mechanism launches the Fire TV home launcher app on the Vega device, which pushes the running app in the background. This behavior is the most common use case in real-world scenarios, where pressing home key executes the same commands to achieve the required behavior. Send the app to backgroundLaunch a new app while an app is in the foreground
Launching another app when the current app is in the foreground also pushes the current app to the background. You can only simulate this behavior if you have multiple apps installed, not including any system services.Invoke Alexa to send an app to the background
You can send your app to the background by invoking Alexa to search for catalog titles. To send your app to the background:- Hold the “voice” button on your remote
- Ask Alexa to search for any content
Mechanisms to handle app state
Vega apps have access toAppState through React Native APIs. You can use AppState to check the current state of the app: “active” or “background”. The app can also register for “change” event listener to get notified of the AppState.
Cleanup your app when pushed to the background
When your app moves to the background, follow these cleanup steps:- Stop content playback - Releases media decoders and playback resources
- Update lifecycle state - Adjust any state tracking for background/foreground status
- Optimize memory - Free up unused memory resources
- Enable warm start - Allow quick app resume from background state

