harmony 鸿蒙Stage Model Development Overview

  • 2023-02-03
  • 浏览 (730)

Stage Model Development Overview

Basic Concepts

The following figure illustrates the stage model.

Figure 1 Stage model stage-concepts

The stage model provides two types of application components: UIAbility and ExtensionAbility. Both have specific classes and support object-oriented development.

  • UIAbility is a type of application component that provides the UI for user interaction. For example, with UIAbility, the Gallery application can display images in the liquid layout. After a user selects an image, it uses a new UI to display the image details. The user can touch the Back button to return to the liquid layout. The lifecycle of the UIAbility component contains the Create, Destroy, Foreground, and Background states. Display-related states are exposed through WindowStage events.

  • ExtensionAbility is used for specific scenarios. You cannot derive directly from ExtensionAbility. Instead, use the derived classes of ExtensionAbility for your scenarios, such as FormExtensionAbility for widget scenarios, InputMethodExtensionAbility for input method scenarios, and WorkSchedulerExtensionAbility for deferred task scenarios. For example, to enable a user to create an application widget on the home screen, you must derive a class from FormExtensionAbility, implement callbacks, and configure the capability in the configuration file. The derived class instances are created by applications and their lifecycles are managed by the system. In the stage model, you must use the derived classes of ExtensionAbility to develop custom services based on your service scenarios.

  • WindowStage

Each UIAbility class instance is bound to a WindowStage class instance, which functions as the window manager in the application process. The WindowStage class instance contains a main window. That is, UIAbility holds a main window through WindowStage, and this window provides a rendering area for ArkUI.

In the stage model, Context and its derived classes provide a variety of resources and capabilities that can be called during the runtime. The UIAbility component and ExtensionAbility derived classes have different Context classes. These classes, which all inherit from the base class Context, provide different capabilities.

Each HAP of the Entry or Feature type has an AbilityStage class instance during the runtime. When the code in the HAP is loaded to the process for the first time, the system creates an AbilityStage class instance. Each UIAbility class defined in the HAP is associated with this class instance after instantiation. Through this class instance, you can obtain the runtime information of the UIAbility instances in the HAP.

How to Develop

During application development based on the stage model, the following tasks are involved in the application model.

Table 1 Stage model development process

Task Description Guide
Application component development Use the UIAbility and ExtensionAbility components of the stage model to develop your application. - Application- or Component-Level Configuration
- UIAbility Component
- ExtensionAbility Component
- AbilityStage Container Component
- Context
- Component Startup Rules
Process model development Learn the process model and common IPC modes of the stage model. - Common Events
- Background Services
Thread model development Learn the thread model and common inter-thread communication modes of the stage model. - Emitter
- Worker
Mission management development Learn the basic concepts and typical scenarios of mission management in the stage model. - Mission Management Scenarios
- Mission Management and Launch Type
- Page Stack and Mission List
Configuration file development Learn the requirements for developing application configuration files in the stage model. Application Configuration File

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Application Models

harmony 鸿蒙Using Explicit Want to Start an Application Component

harmony 鸿蒙Using Implicit Want to Open a Website

harmony 鸿蒙AbilityStage Component Container

harmony 鸿蒙Accessing a DataAbility

harmony 鸿蒙Accessing a DataShareExtensionAbility from the FA Model

harmony 鸿蒙AccessibilityExtensionAbility

harmony 鸿蒙Common action and entities Values

harmony 鸿蒙API Switching Overview

harmony 鸿蒙Switching of app and deviceConfig

0  赞