目录

Application Model Overview

Application Model Overview

An application model is an abstraction of the capabilities required by an application, provided by the system for developers. It provides the essential components and running mechanisms of an application. The application model offers developers a unified development model, making application development simpler and more efficient.

The application model that is currently promoted and will evolve over the long term is the stage model, supported since API 9. This model provides the AbilityStage component manager and the WindowStage window manager, which serve as the "stages" for application components and windows, respectively, hence the name "stage model".

The stage model allows multiple application components to share a single ArkTS engine instance and supports state sharing and object invocation between components. This reduces memory overhead and enhances development efficiency, making it well-suited for complex application development.

  • As the application model evolves, the FA model supported since API 7 is no longer promoted. Currently, the FA model is mainly used for Lite Wearable devices. For details, see Application Model Development Overview.
  • Unless otherwise specified, "application model" mentioned in the documentation refers to the "stage model".

Basic Concepts

The following figure illustrates the stage model.

Figure 1 Stage model

Elements

The elements of the application model mainly include application components, the process model, the thread model, the task management model, and application configuration files.

[h2]Application Components

Application components are the basic building blocks and running entry of an application.

When a user starts, uses, and exits an application, the application components switch between different states, which are called the application component lifecycle.

Application components provide lifecycle callback functions, through which developers can perceive changes in the application state.

When developing an application, developers first need to write the application components and their lifecycle callback functions, and configure the relevant information in the application configuration file. At runtime, the operating system creates application component instances based on the configuration file and schedules their lifecycle callback functions, thereby executing the developer's code.

[h2]Process Model

The process model defines how application processes are created and destroyed, as well as how processes communicate with each other.

[h2]Application Thread Model

The application thread model defines how threads are created and destroyed within an application process, how the main thread and UI thread are created, and how threads communicate with each other.

[h2]Application Task Management Model (System Applications Only)

The application task management model defines how tasks (missions) are created and destroyed, as well as the relationship between tasks and components.

A task is a record of a user using an application component instance. Each time a user starts a new application component instance, a new task is generated.

For example, when a user starts a video application, the video application task is displayed in the recent tasks screen. When the user taps this task, the system switches the task to the foreground. If the video editing feature in this video application is also implemented through an application component, starting the video editing feature creates a video editing application component instance, and both the video application task and the video editing task are displayed in the recent tasks screen.

[h2]Application Configuration File

The application configuration file contains application configuration information, application component information, permission information, and developer-defined information. This information is provided to the compilation tool, application market, and operating system during the compilation, distribution, and running phases, respectively.

[h2]Sample Application Components

The following uses the Demo.app application as an example to describe the development phase and running phase separately, helping you better understand the components of the stage model.

The Demo.app application mainly implements the following features:

Figure 2 Elements of the stage model

Development phase: You need to use the application components provided by the stage model (UIAbility and ExtensionAbility components) to develop application functionalities and register relevant application information in the configuration files (app.json5 and module.json5).

Runtime phase: When the application is installed and running on the device, the system uses a set of application process and thread management mechanisms to ensure orderly operation.