“This is the 8th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”
A list,
1.1 What is a page
Information is organized by page information, information page is realized by language, hypertext links are established between each information page for browsing, this is the page. Pages generally include basic elements such as text, images, tables, and hyperlinks.
2.1 Pages in HarmonyOS
When we open the mobile App, all we see are pages!
HarmonyOS refers to a Page as a Ability, or more accurately, AbilitySlice in Page Ability (the sum of a single Page applied and its control logic).
Second, the Ability
2.1 introduction
Ability is the abstraction of an application’s capabilities (or, I feel, templates, modules) and an important part of the application. An app can have multiple capabilities (i.e., multiple abilities), and HarmonyOS allows applications to be deployed in accordance with Ability.
Ability falls into two categories:
- FA (Feature Ability)
- PA (Particle Ability)
Ability type | Support the template | describe |
---|---|---|
Feature Ability | Page Ability | Page template: Used to provide the ability to interact with users. A Page instance can contain a set of related pages, each represented by an instance of AbilitySlice. |
Particle Ability | Service Ability and Data Ability | Service template: Used to provide the ability to run tasks in the background. Data template: Used to provide a uniform Data access abstraction externally. |
2.2 Page Ability
Page Ability is the only template supported by Feature Ability.
To provide the ability to interact with the user, is actually the parent of the page. A Page can consist of one or more AbilitySlice. AbilitySlice is the sum of an application’s individual pages and their control logic. When a Page is composed of multiple AbilitySlice, the capabilities provided by these AbilitySlice pages should be highly relevant.
\
HarmonyOS allows you to jump between pages and specify a specific AbilitySlice in the target Page.
2.3 the Service Ability
Service Ability is one of the templates supported by Particle Ability.
It is used to run background tasks (such as music playing and file downloading), but does not provide a user interface. A Service can be started by another application or Ability and will continue to run in the background even if the user switches to another application.
A Service is singleton. There is only one instance of the same Service on a device. If multiple Ability shares this instance, a Service can exit only when all Ability bound to it exits. Since a Service is executed in the main thread, if the operation takes too long in the Service, the developer must create a new thread in the Service to prevent the main thread from blocking and the application from becoming unresponsive.
HarmonyOS thread Communication Development Overview
Developer.harmonyos.com/cn/docs/doc…
2.4 Data Ability
Data Ability is one of the templates supported by Particle Ability.
Applications manage access to their own and other applications’ storage data, and provide methods for sharing data with other applications. Data can be shared between different applications on the same device or across different applications on different devices. Data can be stored in various forms, such as databases or files on disk. Data provides external interfaces for adding, deleting, modifying, searching Data, and opening files. The specific implementation of these interfaces is provided by developers.
Design of the HarmonyOS page
3.1 Atomization service and HAP Introduction
One of the things that distinguishes HarmonyOS from traditional apps is that HarmonyOS offers a futuristic approach to service delivery: atomization.
Atomization service can be installed without any need (no display installation is required, it is very convenient for the system background to install on demand), it can run on 1+8+N devices.
Atomized services are compared with traditional apps as follows:
project | Atomization service | Traditional App |
---|---|---|
A packet form | APP Pack(app) | APP Pack(app) |
Distribution platform | Managed and distributed by Huawei Ability Gallery | Managed and distributed by the AppGallery |
Is there a desktop icon after installation | No desktop icon, but can be manually added to the desktop, display format isThe service card | Have a desktop icon |
HAP pack free of installation requirements | allHAP packet (including Entry HAP and Feature HAP)All needs to meetFree installationrequirements | All HAP packs (including Entry HAP and Feature HAP) are not free to install |
Official website address:
Developer.harmonyos.com/cn/docs/doc…
The Atomization service consists of the HAP package, which is the Ability deployment package, and the HarmonyOS application code is built around the Ability component. An HAP is a module package composed of codes, resources, third-party libraries and application configuration files, which can be divided into entry and feature module types.
Details can be found on the official website:
Developer.harmonyos.com/cn/docs/doc…
An atomized service can be composed of one or more HAP, and one HAP corresponds to one FA or one PA. Each FA or PA can run independently to complete a specific function. One or more functions (corresponding to FA or PA) perform a specific convenience service.
So the HarmonyOS App package looks like this:
3.2 Separable and conjunctive thought
According to the structure of the HarmonyOS App package in 3.1, a HarmonyOS App package can be composed of one or more HAP components. The components are optional and can be combined based on user needs and hardware.
For example, a HarmonyOS TV and a mobile phone have some of the following features:
HarmonyOS TV:
HarmonyOS mobile:
The TV does not have the function of texting and calling, but it has the function of controlling channel switching, so it can be installed. HAP; On the other hand, mobile phones have both SMS and call functions, so SMS can be installed. HAP and pass.hap. Both have the functionality of a game, so both can install games. HAP. HarmonyOS’s HAP installation package is designed to be configurable based on the user’s actual needs or hardware.
For different functions, it is recommended to write the same HAP, such as SMS. HAP, this can reduce the complexity of the system downloading installation packages or user field installation when the user uses a particular function.
3.hap Ability
For the game above. HAP, for example, a man will descend 100 floors. We will develop Ability, which has many sub-functions, such as login, registration, games, equipment, chat and so on. These different capabilities can be integrated into different AbilitySlice, one page per AbilitySlice.
The graph of HAP Ability is as follows:
AbilitySlice allows users to log in, register, play, equip, chat, etc., and jump from one AbilitySlice to another to form a running game. HAP