“This is the fifth day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”
Introduction to the HarmonyOS application
Applications generally refer to programs that run on the operating system and provide users with specific services, referred to as “applications”, generally run on mobile phones and tablets!
HarmonyOS operates in two states:
- Traditional applications that require installation
- HarmonyOS specific, installation-free atomization service
The atomization service is described below on the official website:
Atomization service is to provide a future-oriented HarmonyOS service delivery, there is a separate entrance (the user can directly triggered by clicking on the way), free installation (without explicit installation, from the backstage after installation of system application framework can be used), can provide users with one or more convenient service user application form.
The Atomization service is based on the HarmonyOS API and runs on 1+8+N devices, making it easy to use on the right device in the right scenario. Atomized services are lighter than traditional installable forms of applications, while providing richer entry points and more precise distribution.
Atomization service consists of one or more HAP packets, one HAP packet corresponds to one FA or one PA. Each FA or PA can operate independently to complete a specific function; One or more functions (corresponding to FA or PA) perform a specific convenience service.
Atomized services versus traditional installation-required applications:
project | Atomization service | Traditional applications that require installation |
---|---|---|
Software package 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 |
Second, the user application package structure
2.1 Structure Diagram
The HarmonyOS user Application Package is released as APP Pack (Application Package), which consists of one or more HAP (HarmonyOS Ability Package) and pack.info that describes the properties of each HAP. HAP is the Ability deployment package, and the HarmonyOS application code is built around the Ability component.
Here is a basic HelloWord application structure:
2.2 TYPE of HAP module
An HAP consists of code, resource, third-party library and application configuration file. It is divided into two module types: Entry and feature!
Entry: Main application module. An App must have only one entry type HAP for a unified device type, which can be installed and run independently.
Feature: Dynamic feature module of an application. An App can contain one or more HAP features or no HAP features. Only HAP containing Ability can run independently (meaning feature modules that do not contain Abilitu cannot run independently).
Logical view of APP:
2.3 Module Introduction
2.3.1 Ability
Ability is the abstraction of the capabilities of an application, and an application can encompass one or more abilities. Ability comes in two types
- FA(Feature Ability)
- PA(Paticle Ability)
FA/PA is a basic component of an application to realize specific service functions. FA has A UI interface, PA has no UI interface.
2.3.2 library files
The third-party code (JAR, bin, SO, HAR and other binaries) that the application depends on is stored in the liBS directory
2.3.3 Resource Files
Application resource files (images, audio, etc.) are stored in the Resources directory for easy use and maintenance. More on this later.
2.3.4 Configuration Files
The config file (config.json) is the Ability information of the application, used to declare the Ability of the application and the permissions required by the application, etc., which will be described in detail later.
2.3.5 pack. The info
Describes the properties of each HAP in the application package, which is compiled and generated by the IDE, unpacked by the application market and stored by HAP classification. Specific attributes of HAP include:
- Delivery-with-install: indicates whether the HAP can be installed with the application. True: supports the installation with the application. False indicates that the installation with the application is not supported
- Name: HAP file name
- Module-type: indicates the module type, entry or feature
- Device-type: indicates the device type that supports the HAP operation
2.3.6 HAR
HAR (HarmonyOS Ability Resources) provides everything you need to build your application, including source code, resource files, and config.json files. HAR differs from HAP in that HAR cannot be installed and run on the device independently and can only be referenced as a dependency of an application module.