当前位置:网站首页>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 !
边栏推荐
- Which brand of running headphones is good? How many professional running headphones are recommended
- JVM interview
- 【带你学c带你飞】2day 第8章 指针(练习8.1 密码开锁)
- Leetcode face T10 (1-9) array, ByteDance interview sharing
- How does MySQL solve the problem of not releasing space after deleting a large amount of data
- [JSON] gson use and step on the pit
- 【做题打卡】集成每日5题分享(第二期)
- Sword finger offer 47 Maximum value of gifts
- Comparative analysis of MVC, MVP and MVVM, source code analysis
- essay structure
猜你喜欢
批量检测url是否存在cdn—高准确率
[opencv] - comprehensive examples of five image filters
Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
STM32__ 05 - PWM controlled DC motor
What is the principle of bone conduction earphones and who is suitable for bone conduction earphones
Summary of some experiences in the process of R & D platform splitting
Is bone conduction earphone better than traditional earphones? The sound production principle of bone conduction earphones is popular science
LFM信号加噪、时频分析、滤波
Pat a-1165 block reversing (25 points)
Opencascade7.6 compilation
随机推荐
JS slow animation
[JSON] gson use and step on the pit
Face++ realizes face detection in the way of flow
Types of exhibition items available in the multimedia interactive exhibition hall
[liuyubobobo play with leetcode algorithm interview] [00] Course Overview
JVM interview
Software testing learning notes - network knowledge
Duplicate keys detected: ‘0‘. This may cause an update error. found in
CVPR 2022 | 大连理工提出自校准照明框架,用于现实场景的微光图像增强
Sword finger offer 29 Print matrix clockwise
How to run oddish successfully from 0?
Decipher the AI black technology behind sports: figure skating action recognition, multi-mode video classification and wonderful clip editing
RTL8189FS如何关闭Debug信息
STM32F103——两路PWM控制电机
How to turn off the LED light of Rog motherboard
query词权重, 搜索词权重计算
How to use redis ordered collection
Remote connection to MySQL under windows and Linux system
What is the function of the headphone driver
Email picture attachment