Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.
HarmonyOS
API references provide the description of APIs used for application development. This topic describes common fields in the API references to help you better use the reference document.
In API references, the earliest versions of APIs and components are specified in the following ways:
System capability refers to a relatively independent feature in the operating system. Different devices provide different system capabilities, and multiple APIs implement a system capability. You can determine whether an API can be used based on system capabilities. For details, see SystemCapability.
The following description is provided for each API in the reference document to describe the system capability of the API: "System capability: SystemCapability.xxx.xxx"
The open capabilities (APIs) provided by the HarmonyOS SDK can be used only after the declaration is imported. The SDK encapsulates API modules within each kit, allowing you to access these APIs by importing the respective kit in their code. Detailed definitions of the API modules encapsulated in each kit can be found in the kit subdirectory within the SDK directory.
Atomic services take a lightweight application form and feature instant access, cross-device hopping, and more.
Atomic services can be independently released, distributed, and executed to implement service closure, greatly improving the efficiency of obtaining information and services.
Atomic services are developed based on the HarmonyOS SDK (only the Atomic Service API Set can be used) and can run on HarmonyOS devices in proper scenarios.
A service widget (also called widget) is a set of UI components that display important information or operations specific to an application or atomic service. It provides users with direct access to a desired service, without the need to open the application first.
By default, applications can access limited system resources. However, in some cases, an application needs to access excess data (including personal data) and functions of the system or another application to implement extended functions. For details, see Application Permission Management Overview.
To call APIs to access these resources, you must apply for the corresponding permissions by following the instructions provided in Workflow for Requesting Permissions.
You may encounter errors when using ArkTS APIs.
For each API where errors might occur, you can refer to the error code section in the documentation to understand the possible error code IDs and messages for that API and handle them as needed.
ArkTS API includes both asynchronous and synchronous APIs, with the following error handling methods:
For synchronous APIs, errors are uniformly thrown as exceptions, and you need to handle potential exceptions using try-catch.
For asynchronous APIs, errors may include exceptions and rejections. If you use the await/async approach, you need to handle potential exceptions and rejections using try-catch.
For asynchronous APIs using the Promise approach, errors may include exceptions and rejections. You need to handle synchronous exceptions (usually 401 exceptions) using try-catch and handle rejections using the Promise's catch() method or the onrejected callback function in the then() method.
For asynchronous APIs using the callback approach (not recommended), errors may include exceptions and errors returned by the callback. If you use the callback approach, you need to handle synchronous exceptions (usually 401 exceptions) using try-catch and handle errors presented through callback parameters (for example, BusinessError objects).
Along its evolution, the system has provided two application models: FA model and stage model.
A deprecated API is an API no longer recommended and is marked with the deprecated superscript.
While deprecated APIs can still be implemented in the five API levels immediately following the version when the API is deprecated, this is not recommended.
Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.