1 -> Add Ability to the module
Ability is an abstraction of the capabilities that an application/metaservice has, and a module can contain one or more capabilities. The application/metaservice provides two application models:
FA (Feature Ability) model: The model that API 7 has supported since it is no longer recommended.
Stage Model: A model that has been added since HarmonyOS 3.1 Developer Preview, and is currently the main model that will evolve over the long term. In this model, the application model is called the Stage model because classes such as AbilityStage and WindowStage are provided as the "stage" of the application components and the Window window.
The Stage model contains two types of Ability components:
UIAbility component: contains the UI interface, provides the ability to display the UI, and is mainly used for user interaction.
ExtensionAbility: provides the ability to be extended in specific scenarios to meet more usage scenarios.
1.1 -> Add UIAbility to the Stage model
1.1.1 -> Add UIAbility to the module
Select the corresponding module, right-click, and select New > Ability.
- Set the Ability Name, select whether to display the startup icon of the Ability on the home screen of the device, and click Finish to complete the Ability creation.
1.1.2 -> Add Extension Ability to the module
- Select the corresponding module in the project, right-click, select New > Extension Ability, and select a different scene type. Currently, only Application projects support the creation of extension capabilities.
EmbeddedUIExtensionAbility: Provides the ability to embed cross-process interfaces.
BackupAbility: the ability to back up and restore data accessed by an application.
WorkScheduler: provides the ability to delay the implementation of task callbacks.
RemoteNotificationAbility: provides the notification capability for obtaining scenario-based message data and callbacks for lifecycle destruction.
- Set the Ability Name and click Finish to create the Extension Ability.
2 -> Create a service card
2.1 -> Overview
The service card can display the important information of the meta-service/application on the desktop in the form of a card, and users can use the card through shortcut gestures, and achieve the purpose of direct service and reduce level jump through lightweight interaction behavior.
Different SDK versions provide different card templates:
Currently, the following card templates are available:
2.2 -> Constraints on Use
Each module can be configured with up to 16 service cards.
Cards do not support debugging.
Meta services do not support the creation of JS cards.
2.3 -> Create a service card
After you create a project, you can create a service card in the following ways:
- There are two ways to create a service card:
Select any file under the module (for example, the entry module) and click the File > New > Service widget in the menu bar to create a service card.
Select any file under the module (such as the entry module) and right-click the > New > Service Widget to create a service card.
illustrate
If you create a meta-service project or module in a meta-service project or a meta-service project, a service card and an entrycard are no longer created by default.
In projects with API 10 or above Stage models, you can directly select to create a dynamic/static card in the Service Widget menu.
- In the Choose a Template for Your Service widget, select the card template and click Next.
- In the Configure Your Service widget, configure the basic information of the card, including:
Service widget name: the name of the card, which cannot be repeated in the same app/meta service, and can only contain uppercase and lowercase letters, numbers, and underscores.
Display name: The name of the card as it appears on the card preview panel. This field can be configured only for Stage projects that are API 11 or later.
Description: The description of the card.
Language: the language used to create an ArkTS/JS card.
Support dimension: Select the specification of the card. Some cards support multiple specifications at the same time. When you create a service card for the first time, an EntryCard directory will be generated by default to store the card snapshot.
Default dimension: You can select a default card from the drop-down list.
Ability name: Select a Form Ability to attach to the service card, or create a new Form Ability.
Module name: the module to which the card belongs.
- Click Finish to complete the creation of the card. After the creation is complete, the tool automatically creates a layout file of the service card and writes the attribute fields of the service card in the form_config.json file.
- After the card is created, complete the development of the service card according to the development guide.
2.4 -> Create dynamic/static cards
DevEco Studio supports the creation of static/dynamic cards. Dynamic cards support custom interactions, animations, swiping and other functions, which are rich in functions but occupy a large amount of memory; Static cards have a small memory footprint, which helps to optimize the memory of the whole machine, and can display static information, refresh it, and click to jump.
illustrate
Currently, only Stage models with API 10 or later support static card development.
After the service card is created, you can modify the isDynamic parameter configuration in the form_config.json file. isDynamic is left blank or true, the card is dynamic. If the value is false, the card is static.
2.5 -> Preview the service card
During the development of service cards, you can preview the cards in real time. During the development process, you can preview the layout file in real time, and as long as the modified source code is saved in the layout file, you can view the layout effect in real time in the previewer. In the preview effect of the Phone and Tablet service cards, each size of the service card provides three types of scene preview effects, namely Minimum, Default, and Maximum, and developers should ensure that the display effect of the three sizes is normal so as to adapt to devices with different screen sizes.
Top comments (0)