App life cycle
The life cycle of your app can be divided into three basic stages: it starts, runs for some time, and then ends. The BlackBerry 10 Native SDK is a multithreaded, multitasking platform that can run multiple apps at the same time. Most BlackBerry 10 apps have a similar life cycle, which includes three possible states: fullscreen, thumbnail, and invisible. Depending on the permissions granted to your app, these states can mean different things regarding whether an app is running or not.
In the fullscreen state, the app is running in the foreground and can use all the resources that it requires in terms of memory allocation and processor time.
In a Cascades app, when the app enters this state, the fullscreen() signal is emitted.
In a C app, the NAVIGATOR_WINDOW_FULLSCREEN navigator event is sent to the app to notify the app of the change in the window state.
In the thumbnail state, the app is running in the background as an Active Frame. By default, the Active Frame image (also called the cover) is a scaled-down version of what the app's UI looks like when it is sent to the background. However, it's recommended that you create your own active frames when you want to add that bit of extra flare to your app.
When your app is in this state, it should stop any extraneous processing and use only the resources it needs to update the cover. Your app should stop other threads, such as networking and data access threads, that aren't required when running in the background.
In a Cascades app, when the app enters this state, the thumbnail() signal is emitted.
In a C app, the NAVIGATOR_WINDOW_THUMBNAIL navigator event is sent to the app to notify the app of the change in the window state and the app is placed into the NAVIGATOR_APP_BACKGROUND run partition.
In some cases, you might want your app to continue running in a background state, doing a background task such as playing an audio stream. For more information, see Running in the background.
In the invisible state, the app and its Active Frame are no longer visible on the screen. If the device backlight is off or if another app is brought to the foreground, the app might enter this state.
When your app is in this state and doesn't have permission to run in the background, it is stopped and doesn't receive any processing time. If your app has permission to run in the background, your app should stop any rendering operations (for example, updating the UI) and any other unnecessary operations. Your app should listen only for the events that it needs to respond to and process these events when they occur.
In a Cascades app, when the app enters this state, the invisible() signal is emitted.
When the device is in a critical condition, the BlackBerry 10 OS might trigger events that affect your app's life cycle. For example, when the device is out of battery power and turns off, it closes all open apps. If the device is running many memory-intensive apps, a low-memory situation might occur. The BlackBerry 10 OS handles low-memory conditions by closing idle background apps to reclaim memory resources. For more information, see Handling critical conditions.
Last modified: 2015-05-07