as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

Transition App State between Background and Foreground

There are various use cases to move your app between background and foreground states. Testing this transition helps you understand warm launch scenarios of your apps as well as actions you must take when your apps are in the background. This page shows you how to simulate transitions between foreground and background of your app.

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)

The backstack behavior decides if the user can enter back into the backgrounded app by pressing back key.

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 background

Copied to clipboard.

vda shell vlcm launch-app os://home

This command launches the home launcher app. Pressing home RCU button performs the same action as simulated by the above command.

List Apps to Check Which is Visible

You can run the command below to list all the running apps to check if your app is running in the background now.

Copied to clipboard.

vda shell vlcm list

Launch 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.

Copied to clipboard.

vda shell vlcm launch-app orpheus://<appID for another app>

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

This works because Vega devices use universal search, which automatically moves the current app to the background when showing search results.

Bring the app to foreground again

Bringing your app back to the foreground is similar to launching the app again, but in warm start (for example, when the app runs in the background). Run the following command to bring the app to the foreground.

Copied to clipboard.

vda shell vlcm launch-app orpheus://<appID>

Mechanisms to handle app state

Vega apps have access to AppState 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.

Copied to clipboard.

import React, { useRef, useState, useEffect } from 'react';
import { AppState, StyleSheet, Text, View } from 'react-native';

const AppStateExample = () => {
  const appState = useRef(AppState.currentState);
  const [appStateVisible, setAppStateVisible] = useState(appState.current);

  useEffect(() => {
    const subscription = AppState.addEventListener('change', nextAppState => {
      console.log('Current AppState is:', appState.current);
      console.log('Next AppState is:', nextAppState);
      if (
        appState.current.match(/inactive|background/) &&
        nextAppState === 'active'
      ) {
        console.log('App has come to the foreground!');
      }

      appState.current = nextAppState;
      setAppStateVisible(appState.current);
      console.log('AppState:', appState.current);
    });

    return () => {
      subscription.remove();
    };
  }, []);

  return (
    <View style={styles.container}>
      <Text>Current state is: {appStateVisible}</Text>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

export default AppStateExample;

You can learn more about AppState in the React Native for Vega documentation.

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

These steps improve user experience and optimize resource usage.


Last updated: Oct 22, 2025