当前位置:网站首页>Share the basic knowledge of a common Hongmeng application
Share the basic knowledge of a common Hongmeng application
2022-07-02 02:35:00 【A drop in the universe】
What is Hongmeng application
User application generally refers to running on the operating system of the device , Programs that provide specific services to users , abbreviation “ application ”, abbreviation APP.
stay HarmonyOS Applications running on , There are two forms :
- Traditional applications that need to be installed .
- Provide specific functions , Installation free applications ( Atomized services ).
The form of Hongmeng application
Hongmeng application software package to APP Pack(Application Package) Form release , It is composed of one or more HAP(HarmonyOS Ability Package) And describe each HAP Attribute pack.info form .HAP yes [Ability] Deployment package for ,HarmonyOS Application code around Ability Component expansion .
Similar to the common Web application ,HAP Also by code 、 resources 、 Third party libraries and application configuration files .
HAP Can be divided into entry and feature Two module types :
- entry: The main module of the application . One APP in , There must be and only one for the same device type entry Type of HAP, It can be installed and operated independently .
- feature: Dynamic characteristic module of application . One APP Can contain one or more feature Type of HAP, It can also be without . Only contains Ability Of HAP To be able to run independently .

Ability
Ability( Ability , It can be interface capability , It can also be service capability ), It is the basic unit of application software . Abstraction of the capabilities of an application , An application can have multiple capabilities , That is, it can contain multiple Ability, Hongmeng HarmonyOS Support applications to Ability Deploy for the unit .
The library files
Library files are third-party code that applications rely on ( for example so、jar、bin、har Wait for binary ), Store in libs Catalog .
Resource file
The resource file is easy to understand : character string 、 picture 、 Icon 、 Audio etc. . Place in resources Under the table of contents .
resources
|---base // Default existing directory
| |---element
| | |---string.json
| |---media
| | |---icon.png
|---en_GB-vertical-car-mdpi // Examples of qualifier lists , Developers need to create their own
| |---element
| | |---string.json
| |---media
| | |---icon.png
|---rawfile // Default existing directory
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
For details, see Classification and use of resource files
The configuration file
Other under development , The configuration file format can be XML or JSON Format , Hongmeng application also adopts JSON Format , The configuration file is config.json . Configuration files are applied Ability Information , Used to declare the application Ability , And the permissions required by the application .
Each application HAP There is one in the root directory of “config.json” The configuration file , It mainly covers the following three aspects :
- Global configuration information for the application , Contains the package name of the application 、 Manufacturer 、 Basic information such as version number .
- Configuration information applied to specific devices .
- HAP Package configuration information , Include each Ability Basic properties that must be defined ( Such as package name 、 Class name 、 Type and Ability Capabilities provided ), As well as the permissions required for the application to access the system or other protected parts of the application .
This is from the last article HelloWorld In program config.json file :
{
"app": {
"bundleName":
"com.example.helloworld",
"vendor":
"example",
"version": {
"code":
1000000,
"name":
"1.0.0"
}
},
"deviceConfig": {},
"module": {
"package":
"com.example.helloworld",
"name":
".MyApplication",
"mainAbility":
"com.example.helloworld.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall":
true,
"moduleName":
"entry",
"moduleType":
"entry",
"installationFree":
false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation":
"unspecified",
"name":
"com.example.helloworld.MainAbility",
"icon":
"$media:icon",
"description":
"$string:mainability_description",
"label":
"$string:entry_MainAbility",
"type":
"page",
"launchType":
"standard"
}
]
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
For the explanation of the configuration file, please see : The elements of the configuration file
pack.info
Describe each in the application package HAP Properties of , from IDE Compile the generated , The application market unpacks and stores according to this document HAP Classified storage .HAP The specific properties of include :
- delivery-with-install: It means that we should HAP Whether to support installation with application .“true” Indicates that it supports installation with the application ;“false” Indicates that installation with application is not supported .
- name:HAP file name .
- module-type: Module type ,entry or feature .
- device-type: Expressed support for the HA P Type of equipment running .
HAR
HAR(HarmonyOS Ability Resources) It can provide all the content needed to build an application , Including source code 、 Resource files and config.json file .HAR differ HAP ,HAR It cannot be installed and run on the equipment independently , Can only be referenced as a dependency of an application module .
HelloWorld The overall structure of the project
- open HelloWorld After the project , stay Project The preview project structure in the left column is shown in the figure :

We can see that entry Catalog , This directory is actually an application HAP package , The type is entry type .
- Then we are src/main/java Next, you can see the folder named after the package : What is stored here is our Java Code . The code here can be used to create layouts 、 Dynamically adjust the layout and provide support services for interaction .
- and java Folder at the same level resources Application resources are distributed under the directory , The contents of this catalog are base Under the table of contents , According to the classification of resources, there are multiple folders .
- element: Represents an element resource , be lying json File format , It is mainly used to represent string 、 Color value 、 Boolean value , Can be quoted elsewhere .
- graphic: Paintable resources , use xml Documents to show , For example, the fillet button in the project 、 Button color .
- layout: Layout resources , For example, page layout resources
- media: Media resources , Including pictures 、 Audio and video and other non text format files
-
config.json: The configuration file

And main Catalog level test The directory is the test directory , It can be used to unit test the functions written by yourself , Ensure the correctness of the code .
And src A level one libs Directories are used to store or reference third-party packages , for example jar package 、so Bag, etc .
and entry Catalog level build The directory is used to store the final compiled package , That is to say HAP package .
summary
Through the above HelloWorld The application simply explains the files contained in a Hongmeng application 、 Project structure 、 And the functions of each module , Here is just a brief list of some knowledge , For more information, readers are advised to refer to the official documents to learn and understand .
Only familiar with one project structure , To know where to write the code as a developer , isn't it? ?
Hurry to learn . See you in the next article !
边栏推荐
- Comparative analysis of MVC, MVP and MVVM, source code analysis
- [learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table
- 实现一个自定义布局的扫码功能
- 2022安全员-C证考试题及模拟考试
- es面试题
- Sword finger offer 62 The last remaining number in the circle
- 【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
- flutter 中间一个元素,最右边一个元素
- 软件开发生命周期 --瀑布模型
- Opencascade7.6 compilation
猜你喜欢

Comparative analysis of MVC, MVP and MVVM, source code analysis

Formatting logic of SAP ui5 currency amount display

批量检测url是否存在cdn—高准确率

【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表

Architecture evolution from MVC to DDD
Face++ realizes face detection in the way of flow

附加:信息脱敏;

CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决

Leetcode question brushing (10) - sequential question brushing 46 to 50

JPM 2021 most popular paper released (with download)
随机推荐
LFM signal denoising, time-frequency analysis, filtering
query词权重, 搜索词权重计算
[JSON] gson use and step on the pit
An analysis of circuit for quick understanding
How to hide the scroll bar of scroll view in uniapp
Multi threaded query, double efficiency
Deployment practice and problem solving of dash application development environment based on jupyter Lab
how to add one row in the dataframe?
Systemserver service and servicemanager service analysis
LeetCode刷题(十)——顺序刷题46至50
Provincial election + noi Part IV graph theory
The middle element and the rightmost element of the shutter
Email picture attachment
批量检测url是否存在cdn—高准确率
[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
CSDN insertion directory in 1 second
What is the function of the headphone driver
How does MySQL solve the problem of not releasing space after deleting a large amount of data
[untitled]
JVM interview