提交 b9ac3bca 编写于 作者: R RayShih

Merge branch 'master' of https://gitee.com/RayShih/docs

上级 57ac632b 7d7c8919
master OpenHarmony-3.2-Beta2 OpenHarmony-3.2-Beta3 OpenHarmony-3.2-Beta4 OpenHarmony-3.2-Beta5 OpenHarmony-3.2-Release OpenHarmony-4.0-Beta1 OpenHarmony-4.0-Beta2 OpenHarmony_filemanager_develop_20220614 TR4270 bak_OpenHarmony-4.0-Beta1_20230529 docs-modify feature_IDL_20220811 monthly_20220614 monthly_20220816 monthly_20221018 monthly_20230815 revert-merge-17651-master revert-merge-19334-OpenHarmony-4.0-Beta1 revert-merge-19586-master revert-merge-20613-master revert-merge-21757-OpenHarmony-4.0-Beta2 revert-merge-21765-OpenHarmony-4.0-Beta2 revert-merge-23766-master revert-merge-5580-master weekly_20220614 weekly_20220621 weekly_20220628 weekly_20220705 weekly_20220712 weekly_20220719 weekly_20220726 weekly_20220802 weekly_20220809 weekly_20220816 weekly_20220823 weekly_20220830 weekly_20220906 weekly_20220913 weekly_20220920 weekly_20220927 weekly_20221004 weekly_20221011 weekly_20221018 weekly_20221025 weekly_20221101 weekly_20221108 weekly_20221115 weekly_20221122 weekly_20221129 weekly_20221206 weekly_20221213 weekly_20221220 weekly_20221227 weekly_20230103 weekly_20230110 weekly_20230117 weekly_20230124 weekly_20230131 weekly_20230207 weekly_20230214 weekly_20230221 weekly_20230228 weekly_20230307 weekly_20230314 weekly_20230321 weekly_20230328 weekly_20230404 weekly_20230411 weekly_20230418 weekly_20230425 weekly_20230502 weekly_20230509 weekly_20230516 weekly_20230523 weekly_20230530 weekly_20230606 weekly_20230613 weekly_20230619 weekly_20230626 weekly_20230627 weekly_20230704 weekly_20230712 weekly_20230725 weekly_20230801 weekly_20230808 weekly_20230815 weekly_20230822 weekly_20230829 weekly_20230905 OpenHarmony-v4.0-Beta2 OpenHarmony-v4.0-Beta1 OpenHarmony-v3.2.3-Release OpenHarmony-v3.2.2-Release OpenHarmony-v3.2.1-Release OpenHarmony-v3.2-Release OpenHarmony-v3.2-Beta5 OpenHarmony-v3.2-Beta4 OpenHarmony-v3.2-Beta3 OpenHarmony-v3.2-Beta2
无相关合并请求
# Context Usage
## Context Overview
**context** provides the capability of obtaining contextual information of an application.
## Context Structure
**Context** provides the capability of obtaining contextual information of an application.
The OpenHarmony application framework has two models: Feature Ability (FA) model and stage model. Correspondingly, there are two sets of context mechanisms.
The OpenHarmony application framework has two models: Feature Ability (FA) model and stage model. Correspondingly, there are two sets of context mechanisms. **application/BaseContext** is a common context base class. It uses the **stageMode** attribute to specify whether the context is used for the stage model.
**application/BaseContext** is a common context base class, which does not belong to either model. It has only one attribute, **stageMode**, which specifies whether the context is used for the stage model.
- FA Model
The FA model has only one type of context: **app/Context**. Both the application-level context and ability-level context are instances of this type. If an ability-level method is invoked in the application-level context, an error occurs. Therefore, you must pay attention to the actual meaning of the context instance.
Only the methods in **app/Context** can be used for the context in the FA model. Both the application-level context and ability-level context are instances of this type. If an ability-level method is invoked in the application-level context, an error occurs. Therefore, you must pay attention to the actual meaning of the **Context** instance.
The stage model has six types of contexts: **application/Context**, **application/AbilityStageContext**, **application/ExtensionContext**, **application/AbilityContext**, **application/FormExtensionContext**, and **application/ServiceExtensionContext**. For details about these contexts and how to use them, see [Context in the Stage Model](#context-in-the-stage-model).
- Stage Model
The stage model has the following types of contexts: **application/Context**, **application/ApplicationContext**, **application/AbilityStageContext**, **application/ExtensionContext**, **application/AbilityContext**, and **application/FormExtensionContext**. For details about these contexts and how to use them, see [Context in the Stage Model](#context-in-the-stage-model).
![contextIntroduction](figures/contextIntroduction.png)
......@@ -22,77 +22,103 @@ Only the methods in **app/Context** can be used for the context in the FA model.
The FA model has only one context definition. All capabilities in the context are provided through methods. The context uses these methods to extend the capabilities of the FA.
The context is defined in the d.ts file below:
**d.ts statement**
https://gitee.com/openharmony/interface_sdk-js/blob/master/api/app/context.d.ts
Use the context as follows:
**Example**
```javascript
// 1. Import featureAbility.
import featureAbility from '@ohos.ability.featureAbility'
export default {
onCreate() {
console.log('Application onCreate')
// 2. Obtain the context.
// Obtain the context and call related APIs.
let context = featureAbility.getContext();
// 3. Call the methods.
context.setShowOnLockScreen(false, (data) => {
console.log("data: " + JSON.stringify(data));
context.getBundleName((data, bundleName)=>{
console.info("ability bundleName:" + bundleName)
});
},
onActive() {
console.log('Application onActive')
console.info('Application onCreate')
},
onDestroy() {
console.log('Application onDestroy')
console.info('Application onDestroy')
},
}
```
## Context in the Stage Model
The stage model has six contexts. The following describes these contexts in detail.
The following describes the contexts provided by the stage model in detail.
### application/Context
**Overview**
**application/Context** is the base class context that provides basic application information such as **resourceManager**, **applicationInfo**, **cacheDir**, and **area**. It also provides basic application methods such as **createBundleContext**.
**d.ts statement**
https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/Context.d.ts
### application/ApplicationContext
**application/Context** is the base class context that provides basic application information such as **resourceManager**, **applicationInfo**, and **cacheDir**. It also provides basic application methods such as **createBundleContext** and **switchArea**. The application-level context is of the **application/Context** type.
**application/ApplicationContext** is an application-level context. In addition to the capabilities provided by the base class context, the application-level context provides **registerAbilityLifecycleCallback** and **unregisterAbilityLifecycleCallback** to monitor the ability lifecycle in a process.
**How to Obtain**
Obtain the context by calling **context.getApplicationContext()** in **AbilityStage**, **Ability**, and **Extension**.
Obtain the context by calling **context.getApplicationContext()** in **Ability**.
**Example**
```javascript
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate is called' + want + launchParam);
// Obtain the application context.
let appContext = this.context.getApplicationContext();
// Obtain the path.
console.log('filesDir is ' + appContext.filesDir);
}
import AbilityStage from "@ohos.application.AbilityStage";
onDestroy() {
console.log('MainAbility onDestroy is called');
}
var lifecycleid;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
let AbilityLifecycleCallback = {
onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
},
onAbilityWindowStageCreate(ability){
console.log("AbilityLifecycleCallback onAbilityWindowStageCreate ability:" + JSON.stringify(ability));
},
onAbilityWindowStageDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityWindowStageDestroy ability:" + JSON.stringify(ability));
},
onAbilityDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
},
onAbilityForeground(ability){
console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability));
},
onAbilityBackground(ability){
console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability));
},
onAbilityContinue(ability){
console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability));
}
}
// 1. Obtain applicationContext through the context attribute.
let applicationContext = this.context.getApplicationContext();
// 2. Use applicationContext to register and listen for the ability lifecycle in the application.
lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
}
onDestroy() {
let applicationContext = this.context.getApplicationContext();
applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => {
console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
});
}
}
```
**d.ts statement**
https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/Context.d.ts
https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ApplicationContext.d.ts
### application/AbilityStageContext
**Overview**
**application/AbilityStageContext** is the context for the HAP file. In addition to those provided by the base class **application/Context**, this context contains **HapModuleInfo** and **Configuration**.
**How to Obtain**
......@@ -105,7 +131,7 @@ Obtain the context from the **context** attribute in **AbilityStage**.
export default class MyAbilityStage extends AbilityStage {
onCreate() {
// The context attribute is of the AbilityStageContext type.
console.log('HapModuleInfo is ' + context.currentHapModuleInfo);
console.log('HapModuleInfo is ' + this.context.currentHapModuleInfo);
}
}
```
......@@ -116,8 +142,6 @@ https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/Abili
### application/AbilityContext
**Overview**
In the stage model, each ability has a context attribute.
**Ability** provides methods to manage the ability lifecycle, and **AbilityContext** provides methods to operate abilities (such as **startAbility** and **connectAbility**).
......@@ -129,109 +153,53 @@ Obtain the context from the **context** attribute in **Ability**.
**Example**
```javascript
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('MainAbility onCreate is called' + want + launchParam);
var want = {
"bundleName": "com.example.MyApplication",
"abilityName": "ServiceExtAbility",
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
// 1. The context here is of the AbilityContext type.
let contxt = this.context;
// 2. Start the ability.
contxt.startAbility(want).then((data) => {
console.info("startAbility success:" + JSON.stringify(data));
}).catch((error) => {
console.error("startAbility failed:" + JSON.stringify(error));
});
}
onDestroy() {
console.log("MainAbility on Destroy is called");
}
}
```
**d.ts statement**
https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/AbilityContext.d.ts
### application/ExtensionContext
**Overview**
Unlike the FA model, the stage model separates **Service** from **Ability** and defines a group of **Extension** classes to provide the same capabilities. **Extension** is a base class and does not provide specific service functions. The service party extends the corresponding **Extension** class as required. For example, a Service ability is extended to **ServiceExtensionAbility**, and a form (service widget) is extended to **FormExtensionAbility**.
**ExtensionContext** provides the context for the extension. **ExtensionContext** has the **HapModuleInfo** and **Configuration** attributes.
**How to Obtain**
This type of context is not used independently.
**d.ts statement**
https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ExtensionContext.d.ts
### application/ServiceExtensionContext
**Overview**
Similar to **ServiceAbility** of the FA model, **ServiceExtensionAbility** contains only the processing related to lifecycle callbacks.
The methods for operating the Service Extension ability (such as **startAbility** and **connectAbility**) are provided in **ServiceExtensionContext**.
**How to Obtain**
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
Obtain the context from the **context** attribute in **ServiceExtensionAbility**.
onWindowStageCreate(windowStage) {
// Set the main page for this ability when the main window is created.
console.log("[Demo] MainAbility onWindowStageCreate")
**Example**
```javascript
export default class ServiceExtAbility extends ServiceExtensionAbility {
onCreate(want) {
console.info("ServiceAbility onCreate**");
// The context here is of the ServiceExtensionContext type.
let contxt = this.context;
}
onRequest(want, startId) {
console.info("ServiceAbility onRequest**");
}
// Obtain AbilityContext and print the ability information.
let context = this.context;
console.log("[Demo] MainAbility bundleName " + context.abilityInfo.bundleName)
onConnect(want) {
console.info("ServiceAbility onConnect**");
return new StubTest("test");
}
windowStage.setUIContent(this.context, "pages/index", null)
}
onDisconnect(want) {
console.info("ServiceAbility onDisconnect**");
}
onWindowStageDestroy() {
// Release the UI related resources when the main window is destroyed.
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onDestroy() {
console.info("ServiceAbility onDestroy**");
}
}
onForeground() {
// The ability is switched to run in the foreground.
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// The ability is switched to run in the background.
console.log("[Demo] MainAbility onBackground")
}
};
```
**d.ts statement**
https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/ServiceExtensionContext.d.ts
### application/FormExtensionContext
For details, see [FormExtensionContext](/en/application-dev/reference/apis/js-apis-formextensioncontext.md)
**d.ts statement**
https://gitee.com/openharmony/interface_sdk-js/blob/master/api/application/FormExtensionContext.d.ts
## FAQs
Can I obtain the context through globalThis?
For details, see [FormExtensionContext](/en/application-dev/reference/apis/js-apis-formextensioncontext.md).
**Answer**
## Common Incorrect Usage
You can use **globalThis** to obtain the context in the FA model, but not in the stage model. To obtain the context in the stage model, use the **context** attribute in the corresponding component.
**Error 1: Use globalThis to obtain the context in the stage model.**
**Reason**
......
......@@ -65,7 +65,7 @@ A Service ability is used to run tasks in the background, such as playing music
### Starting a Service ability
### Starting a Service Ability
The **Ability** class provides the **startAbility()** API for you to start another Service ability by passing a **Want** object.
......@@ -95,7 +95,7 @@ After the preceding code is executed, the **startAbility()** API is called to st
### Stopping a Service ability
### Stopping a Service Ability
Once created, the Service ability keeps running in the background. The system does not stop or destroy it unless memory resources must be reclaimed. You can call **terminateSelf()** on a Service ability to stop it.
......
en/application-dev/ability/figures/contextIntroduction.png

48.4 KB | W: 0px | H: 0px

en/application-dev/ability/figures/contextIntroduction.png

101.0 KB | W: 0px | H: 0px

en/application-dev/ability/figures/contextIntroduction.png
en/application-dev/ability/figures/contextIntroduction.png
en/application-dev/ability/figures/contextIntroduction.png
en/application-dev/ability/figures/contextIntroduction.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -27,6 +27,8 @@ The table below describes the ability call APIs. For details, see [Ability](../r
|void onRelease(callback: OnReleaseCallBack)|Caller.onRelease: registers a callback that is invoked when the caller is disconnected.|
## How to Develop
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The sample code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently. For details about the complete project code, see [Samples](#samples).
### Creating a Callee
For the callee, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use the **on** API to register a listener. When data does not need to be received, use the **off** API to deregister the listener.
1. Configure the ability startup mode.
......@@ -55,7 +57,7 @@ import Ability from '@ohos.application.Ability'
```
3. Define the agreed sequenceable data.
The data formats sent and received by the caller and callee must be consistent. In the following example, the data consists of numbers and strings. The sample code is as follows:
The data formats sent and received by the caller and callee must be consistent. In the following example, the data consists of numbers and strings. The sample code snippet is as follows:
```ts
export default class MySequenceable {
num: number = 0
......@@ -81,7 +83,7 @@ export default class MySequenceable {
```
4. Implement **Callee.on** and **Callee.off**.
The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **CalleeSortMethod** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows:
The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **CalleeSortMethod** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code snippet is as follows:
```ts
const TAG: string = '[CalleeAbility]'
const MSG_SEND_METHOD: string = 'CallSendMsg'
......@@ -125,7 +127,7 @@ import Ability from '@ohos.application.Ability'
```
2. Obtain the caller interface.
The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller interface of the ability. The following example uses **this.context** to obtain the **context** attribute of the **Ability** instance, uses **startAbilityByCall** to start the callee, obtain the caller interface, and register the **onRelease** listener of the caller. You need to implement processing based on service requirements. The sample code is as follows:
The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller interface of the ability. The following example uses **this.context** to obtain the **context** attribute of the **Ability** instance, uses **startAbilityByCall** to start the callee, obtain the caller interface, and register the **onRelease** listener of the caller. You need to implement processing based on service requirements. The sample code snippet is as follows:
```ts
async onButtonGetCaller() {
try {
......@@ -146,7 +148,7 @@ async onButtonGetCaller() {
console.error(TAG + 'get caller failed with ' + error)
})
```
In the cross-device scenario, you need to specify the ID of the peer device. The sample code is as follows:
In the cross-device scenario, you need to specify the ID of the peer device. The sample code snippet is as follows:
```ts
let TAG = '[MainAbility] '
var caller = undefined
......@@ -170,7 +172,7 @@ context.startAbilityByCall({
console.error(TAG + 'get remote caller failed with ' + error)
})
```
Obtain the ID of the peer device from **DeviceManager**. Note that the **getTrustedDeviceListSync** API is open only to system applications. The sample code is as follows:
Obtain the ID of the peer device from **DeviceManager**. Note that the **getTrustedDeviceListSync** API is open only to system applications. The sample code snippet is as follows:
```ts
import deviceManager from '@ohos.distributedHardware.deviceManager';
var dmClass;
......@@ -188,7 +190,7 @@ function getRemoteDeviceId() {
}
}
```
In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code is as follows:
In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code snippet is as follows:
```ts
let context = this.context
let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']
......@@ -200,7 +202,7 @@ context.requestPermissionsFromUser(permissions).then((data) => {
```
3. Send agreed sequenceable data.
The sequenceable data can be sent to the callee with or without a return value. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code is as follows:
The sequenceable data can be sent to the callee with or without a return value. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code snippet is as follows:
```ts
const MSG_SEND_METHOD: string = 'CallSendMsg'
async onButtonCall() {
......@@ -213,7 +215,7 @@ async onButtonCall() {
}
```
In the following, **CallWithResult** is used to send data **originMsg** to the callee and assign the data processed by the **CallSendMsg** method to **backMsg**. The sample code is as follows:
In the following, **CallWithResult** is used to send data **originMsg** to the callee and assign the data processed by the **CallSendMsg** method to **backMsg**. The sample code snippet is as follows:
```ts
const MSG_SEND_METHOD: string = 'CallSendMsg'
originMsg: string = ''
......@@ -235,7 +237,7 @@ async onButtonCallWithResult(originMsg, backMsg) {
```
4. Release the caller interface.
When the caller interface is no longer required, call the **release** API to release it. The sample code is as follows:
When the caller interface is no longer required, call the **release** API to release it. The sample code snippet is as follows:
```ts
try {
this.caller.release()
......@@ -248,4 +250,4 @@ try {
## Samples
The following sample is provided to help you better understand how to develop an ability call in the stage model:
- [`StageCallAbility`: Stage Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
- [`StageCallAbility`: Stage Call Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
......@@ -2,3 +2,4 @@
- [Agent-Powered Scheduled Reminder Overview](background-agent-scheduled-reminder-overview.md)
- [Agent-Powered Scheduled Reminder Development](background-agent-scheduled-reminder-guide.md)
......@@ -8,7 +8,7 @@ You can set your application to call the **ReminderRequest** class to create s
**reminderAgent** encapsulates the methods for publishing and canceling reminders.
**Table 1** Major APIs in reminderAgent
**Table 1** Major APIs in reminderAgent
<a name="table1731550155318"></a>
<table><thead align="left"><tr id="row4419501537"><th class="cellrowborder" valign="top" width="57.38999999999999%" id="mcps1.2.3.1.1"><p id="p54150165315"><a name="p54150165315"></a><a name="p54150165315"></a>API</p>
......@@ -59,7 +59,7 @@ You can set your application to call the **ReminderRequest** class to create s
**ActionButtonType** enumerates types of buttons displayed in a reminder notification.
**Table 2** ActionButtonType enumeration
**Table 2** ActionButtonType enumeration
<a name="table8534712161513"></a>
<table><thead align="left"><tr id="row14540181231510"><th class="cellrowborder" valign="top" width="38.190000000000005%" id="mcps1.2.3.1.1"><p id="p1454718124159"><a name="p1454718124159"></a><a name="p1454718124159"></a>Name</p>
......@@ -78,7 +78,7 @@ You can set your application to call the **ReminderRequest** class to create s
**ReminderType** enumerates the reminder types.
**Table 3** ReminderType enumeration
**Table 3** ReminderType enumeration
<a name="table486010552014"></a>
<table><thead align="left"><tr id="row2866856201"><th class="cellrowborder" valign="top" width="39.06%" id="mcps1.2.3.1.1"><p id="p986695162012"><a name="p986695162012"></a><a name="p986695162012"></a>Name</p>
......@@ -107,7 +107,7 @@ You can set your application to call the **ReminderRequest** class to create s
**ActionButton** defines a button displayed in the reminder notification.
**Table 4** ActionButton instance
**Table 4** ActionButton instance
<a name="table880311117225"></a>
<table><thead align="left"><tr id="row1480321118225"><th class="cellrowborder" valign="top" width="23.630000000000003%" id="mcps1.2.5.1.1"><p id="p1180321117222"><a name="p1180321117222"></a><a name="p1180321117222"></a>Name</p>
......@@ -143,7 +143,7 @@ You can set your application to call the **ReminderRequest** class to create s
**WantAgent** sets the package and ability that are redirected to when the reminder notification is clicked.
**Table 5** WantAgent instance
**Table 5** WantAgent instance
<a name="table9490856350"></a>
<table><thead align="left"><tr id="row84962056352"><th class="cellrowborder" valign="top" width="23.917608239176083%" id="mcps1.2.5.1.1"><p id="p1849612519352"><a name="p1849612519352"></a><a name="p1849612519352"></a>Name</p>
......@@ -179,7 +179,7 @@ You can set your application to call the **ReminderRequest** class to create s
**MaxScreenWantAgent** sets the name of the target package and ability to start automatically when the reminder arrives and the device is not in use. If the device is in use, a notification will be displayed.
**Table 6** MaxScreenWantAgent instance
**Table 6** MaxScreenWantAgent instance
<a name="table191319843714"></a>
<table><thead align="left"><tr id="row9131814374"><th class="cellrowborder" valign="top" width="24.44%" id="mcps1.2.5.1.1"><p id="p0131810372"><a name="p0131810372"></a><a name="p0131810372"></a>Name</p>
......@@ -215,7 +215,7 @@ You can set your application to call the **ReminderRequest** class to create s
**ReminderRequest** defines the reminder to publish.
**Table 7** ReminderRequest instance
**Table 7** ReminderRequest instance
<a name="table121851239193814"></a>
<table><thead align="left"><tr id="row1019153914389"><th class="cellrowborder" valign="top" width="24.94%" id="mcps1.2.5.1.1"><p id="p712019463387"><a name="p712019463387"></a><a name="p712019463387"></a>Name</p>
......@@ -342,7 +342,7 @@ You can set your application to call the **ReminderRequest** class to create s
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.2.5.1.3 "><p id="p41151626144814"><a name="p41151626144814"></a><a name="p41151626144814"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="50.480000000000004%" headers="mcps1.2.5.1.4 "><p id="p193705238459"><a name="p193705238459"></a><a name="p193705238459"></a>Type of the slot used by the reminder</p>
<td class="cellrowborder" valign="top" width="50.480000000000004%" headers="mcps1.2.5.1.4 "><p id="p193705238459"><a name="p193705238459"></a><a name="p193705238459"></a>Type of the slot used by the reminder.</p>
</td>
</tr>
</tbody>
......@@ -352,7 +352,7 @@ You can set your application to call the **ReminderRequest** class to create s
For the application to run properly, if both **repeatMonths** and **repeatDays** are not specified, the earliest reminder time must be later than the current time.
**Table 8** ReminderRequestCalendar instance
**Table 8** ReminderRequestCalendar instance
<a name="table19307315135210"></a>
......@@ -398,7 +398,7 @@ For the application to run properly, if both **repeatMonths** and **repeatDays**
**ReminderRequestAlarm** extends **ReminderRequest** and defines a reminder for the alarm clock.
**Table 9** ReminderRequestAlarm instance
**Table 9** ReminderRequestAlarm instance
<a name="table187631616124414"></a>
<table><thead align="left"><tr id="row87697166445"><th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.1"><p id="p6561172104414"><a name="p6561172104414"></a><a name="p6561172104414"></a>Name</p>
......@@ -443,7 +443,7 @@ For the application to run properly, if both **repeatMonths** and **repeatDays**
**ReminderRequestTimer** extends **ReminderRequest** and defines a reminder for a scheduled timer.
**Table 10** ReminderRequestTimer instance
**Table 10** ReminderRequestTimer instance
<a name="table7213172015507"></a>
<table><thead align="left"><tr id="row72131520155017"><th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.1"><p id="p6603124145017"><a name="p6603124145017"></a><a name="p6603124145017"></a>Name</p>
......@@ -470,7 +470,7 @@ For the application to run properly, if both **repeatMonths** and **repeatDays**
**LocalDateTime** defines a **LocalDateTime** instance.
**Table 11** LocalDateTime instance
**Table 11** LocalDateTime instance
<a name="table16133167515"></a>
<table><thead align="left"><tr id="row161321615517"><th class="cellrowborder" valign="top" width="25%" id="mcps1.2.5.1.1"><p id="p5894111825115"><a name="p5894111825115"></a><a name="p5894111825115"></a>Name</p>
......@@ -542,7 +542,7 @@ For the application to run properly, if both **repeatMonths** and **repeatDays**
## How to Develop<a name="section4207112818418"></a>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>**NOTE**<br>
>To publish a reminder, your application needs to apply for the **ohos.permission.PUBLISH\_AGENT\_REMINDER** permission.
Publish a 10-second countdown reminder.
......@@ -593,7 +593,7 @@ Publish a 10-second countdown reminder.
}
```
HTML page code:
HML page code:
```
<div class="container">
......
......@@ -8,13 +8,15 @@
- [Audio Rendering Development](audio-renderer.md)
- [Audio Capture Development](audio-capturer.md)
- [OpenSL ES Audio Playback Development](opensles-playback.md)
- [OpenSL ES Audio Recording Development](opensles-capture.md)
- Video
- [Video Playback Development](video-playback.md)
- [Video Recording Development](video-recorder.md)
- Image
- [Image Development](image.md)
- Camera
- [Camera Development](camera.md)
# Camera Development
## When to Use
You can use the camera module to develop basic camera functions, including previewing, photographing, and video recording.
## How to Develop
### Available APIs
For details about the APIs, see [Camera Management](../reference/apis/js-apis-camera.md).
### Full-Process Scenario
The full process includes creating an instance, setting parameters, managing sessions, taking photos, recording videos, and releasing resources.
The method for creating an XComponent is also provided. For details, see [XComponent Creation](#xcomponent-creation).
For details about the APIs used to save images, see [Image Processing](../reference/apis/js-apis-image.md).
#### Creating an Instance
```js
import camera from '@ohos.multimedia.camera'
import image from '@ohos.multimedia.image'
import media from '@ohos.multimedia.media'
import featureAbility from '@ohos.ability.featureAbility'
// Create a CameraManager object.
let cameraManager
await camera.getCameraManager(globalThis.Context, (err, manager) => {
if (err) {
console.error('Failed to get the CameraManager instance ${err.message}');
return;
}
console.log('Callback returned with the CameraManager instance');
cameraManager = manager
})
// Register a callback to listen for camera status changes and obtain the updated camera status information.
cameraManager.on('cameraStatus', (cameraStatusInfo) => {
console.log('camera : ' + cameraStatusInfo.camera.cameraId);
console.log('status: ' + cameraStatusInfo.status);
})
// Obtain the camera list.
let cameraArray
await cameraManager.getCameras((err, cameras) => {
if (err) {
console.error('Failed to get the cameras. ${err.message}');
return;
}
console.log('Callback returned with an array of supported cameras: ' + cameras.length);
cameraArray = cameras
})
for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex) {
console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // Obtain the camera ID.
console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // Obtain the camera position.
console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // Obtain the camera type.
console.log('connectionType : ' + cameraArray[cameraIndex].connectionType) // Obtain the camera connection type.
}
// Create a camera input stream.
let cameraInput
await cameraManager.createCameraInput(cameraArray[0].cameraId).then((input) => {
console.log('Promise returned with the CameraInput instance');
cameraInput = input
})
// Create a preview output stream.
let previewOutput
camera.createPreviewOutput((globalThis.surfaceId), (err, output) => {
if (err) {
console.error('Failed to create the PreviewOutput instance. ${err.message}');
return;
}
console.log('Callback returned with previewOutput instance');
previewOutput = output
});
// Create an ImageReceiver object and set image parameters.
let imageReceiver = await image.createImageReceiver(1920, 1080, 4, 8)
// Obtain the surface ID for displaying the photos.
let photoSurfaceId = await imageReceiver.getReceivingSurfaceId()
// Create a photographing output stream.
let photoOutput
camera.createPhotoOutput((photoSurfaceId), (err, output) => {
if (err) {
console.error('Failed to create the PhotoOutput instance. ${err.message}');
return;
}
console.log('Callback returned with the PhotoOutput instance.');
photoOutput = output
});
// Define video recording parameters.
let videoProfile = {
audioBitrate : 48000,
audioChannels : 2,
audioCodec : 'audio/mp4a-latm',
audioSampleRate : 48000,
fileFormat : 'mp4',
videoBitrate : 48000,
videoCodec : 'video/mp4v-es',
videoFrameWidth : 640,
videoFrameHeight : 480,
videoFrameRate : 30
}
let videoConfig = {
audioSourceType : 1,
videoSourceType : 0,
profile : videoProfile,
url : 'file:///data/media/01.mp4',
orientationHint : 0,
location : { latitude : 30, longitude : 130 },
}
// Create a video recording output stream.
let videoRecorder
await media.createVideoRecorder().then((recorder) => {
console.log('createVideoRecorder called')
videoRecorder = recorder
})
// Set video recording parameters.
await videoRecorder.prepare(videoConfig)
// Obtain the surface ID for video recording.
await videoRecorder.getInputSurface().then((id) => {
console.log('getInputSurface called')
videoSurfaceId = id
})
```
For details about how to create a video recorder, see [Video Recording Development](./video-recorder.md).
```js
// Create a VideoOutput object.
let videoOutput
camera.createVideoOutput((surfaceId), (err, output) => {
if (err) {
console.error('Failed to create the VideoOutput instance. ${err.message}');
return;
}
console.log('Callback returned with the VideoOutput instance');
videoOutput = output
});
```
#### Setting Parameters
```js
// Check whether the camera has flash.
let flashStatus
await cameraInput.hasFlash().then((status) => {
console.log('Promise returned with the flash light support status:' + status);
flashStatus = status
})
if(flashStatus) {
// Check whether the auto flash mode is supported.
let flashModeStatus
cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
if (err) {
console.error('Failed to check whether the flash mode is supported. ${err.message}');
return;
}
console.log('Callback returned with the flash mode support status: ' + status);
flashModeStatus = status
})
if(flashModeStatus) {
// Set the flash mode to auto.
cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
if (err) {
console.error('Failed to set the flash mode ${err.message}');
return;
}
console.log('Callback returned with the successful execution of setFlashMode.');
})
}
}
// Check whether the continuous auto focus is supported.
let focusModeStatus
cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (err, status) => {
if (err) {
console.error('Failed to check whether the focus mode is supported. ${err.message}');
return;
}
console.log('Callback returned with the focus mode support status: ' + status);
focusModeStatus = status
})
if(focusModeStatus) {
// Set the focus mode to continuous auto focus.
cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (err) => {
if (err) {
console.error('Failed to set the focus mode ${err.message}');
return;
}
console.log('Callback returned with the successful execution of setFocusMode.');
})
}
// Obtain the zoom ratio range supported by the camera.
let zoomRatioRange
cameraInput.getZoomRatioRange((err, range) => {
if (err) {
console.error('Failed to get the zoom ratio range. ${err.message}');
return;
}
console.log('Callback returned with zoom ratio range: ' + range.length);
zoomRatioRange = range
})
// Set a zoom ratio.
cameraInput.setZoomRatio(zoomRatioRange[0], (err) => {
if (err) {
console.error('Failed to set the zoom ratio value ${err.message}');
return;
}
console.log('Callback returned with the successful execution of setZoomRatio.');
})
```
#### Managing Sessions
##### Creating a Session
```js
// Create a Context object.
let context = featureAbility.getContext()
// Create a session.
let captureSession
await camera.createCaptureSession((context), (err, session) => {
if (err) {
console.error('Failed to create the CaptureSession instance. ${err.message}');
return;
}
console.log('Callback returned with the CaptureSession instance.' + session);
captureSession = session
});
// Start configuration for the session.
await captureSession.beginConfig((err) => {
if (err) {
console.error('Failed to start the configuration. ${err.message}');
return;
}
console.log('Callback invoked to indicate the begin config success.');
});
// Add the camera input stream to the session.
await captureSession.addInput(cameraInput, (err) => {
if (err) {
console.error('Failed to add the CameraInput instance. ${err.message}');
return;
}
console.log('Callback invoked to indicate that the CameraInput instance is added.');
});
// Add the preview input stream to the session.
await captureSession.addOutput(previewOutput, (err) => {
if (err) {
console.error('Failed to add the PreviewOutput instance ${err.message}');
return;
}
console.log('Callback invoked to indicate that the PreviewOutput instance is added.');
});
// Add the photographing output stream to the session.
await captureSession.addOutput(photoOutput, (err) => {
if (err) {
console.error('Failed to add the PhotoOutput instance ${err.message}');
return;
}
console.log('Callback invoked to indicate that the PhotoOutput instance is added.');
});
// Commit the session configuration.
await captureSession.commitConfig((err) => {
if (err) {
console.error('Failed to commit the configuration. ${err.message}');
return;
}
console.log('Callback invoked to indicate the commit config success.');
});
// Start the session.
await captureSession.start().then(() => {
console.log('Promise returned to indicate the session start success.');
})
```
##### Switching a Session
```js
// Stop the current session.
await captureSession.stop((err) => {
if (err) {
console.error('Failed to stop the session ${err.message}');
return;
}
console.log('Callback invoked to indicate the session stop success.');
});
// Start configuration for the session.
await captureSession.beginConfig((err) => {
if (err) {
console.error('Failed to start the configuration. ${err.message}');
return;
}
console.log('Callback invoked to indicate the begin config success.');
});
// Remove the photographing output stream from the session.
await captureSession.removeOutput(photoOutput, (err) => {
if (err) {
console.error('Failed to remove the PhotoOutput instance. ${err.message}');
return;
}
console.log('Callback invoked to indicate that the PhotoOutput instance is removed.');
});
// Add a video recording output stream to the session.
await captureSession.addOutput(videoOutput, (err) => {
if (err) {
console.error('Failed to add the VideoOutput instance ${err.message}');
return;
}
console.log('Callback invoked to indicate that the VideoOutput instance is added.');
});
// Commit the session configuration.
await captureSession.commitConfig((err) => {
if (err) {
console.error('Failed to commit the configuration. ${err.message}');
return;
}
console.log('Callback invoked to indicate the commit config success.');
});
// Start the session.
await captureSession.start().then(() => {
console.log('Promise returned to indicate the session start success.');
})
```
#### Taking Photos
```js
let settings = {
quality: camera.QualityLevel.QUALITY_LEVEL_HIGH // Set the image quality to high.
rotation: camera.ImageRotation.ROTATION_0, // Set the image rotation angle to 0.
}
// Use the current photographing settings to take photos.
photoOutput.capture(settings, (err) => {
if (err) {
console.error('Failed to capture the photo ${err.message}');
return;
}
console.log('Callback invoked to indicate the photo capture request success.');
});
```
#### Recording Videos
```js
// Start the video recording output stream.
videoOutput.start((err) => {
if (err) {
console.error('Failed to start the video output ${err.message}');
return;
}
console.log('Callback invoked to indicate the video output start success.');
});
// Start video recording.
await videoRecorder.start().then(() => {
console.info('videoRecorder start success');
}
// Stop video recording.
await videoRecorder.stop().then(() => {
console.info('stop success');
}
// Stop the video recording output stream.
await videoOutput.stop((err) => {
if (err) {
console.error('Failed to stop the video output ${err.message}');
return;
}
console.log('Callback invoked to indicate the video output stop success.');
});
```
#### Releasing Resources
```js
// Stop the current session.
await captureSession.stop((err) => {
if (err) {
console.error('Failed to stop the session ${err.message}');
return;
}
console.log('Callback invoked to indicate the session stop success.');
});
// Release the camera input stream.
await cameraInput.release((err) => {
if (err) {
console.error('Failed to release the CameraInput instance ${err.message}');
return;
}
console.log('Callback invoked to indicate that the CameraInput instance is released successfully.');
});
// Release the preview output stream.
await previewOutput.release((err) => {
if (err) {
console.error('Failed to release the PreviewOutput instance ${err.message}');
return;
}
console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.');
});
// Release the photographing output stream.
await photoOutput.release((err) => {
if (err) {
console.error('Failed to release the PhotoOutput instance ${err.message}');
return;
}
console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.');
});
// Release the video recording output stream.
await videoOutput.release((err) => {
if (err) {
console.error('Failed to release the VideoOutput instance ${err.message}');
return;
}
console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.');
});
// Release the session.
await captureSession.release((err) => {
if (err) {
console.error('Failed to release the CaptureSession instance ${err.message}');
return;
}
console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.');
});
```
#### XComponent Creation
The surface ID must be obtained for image preview.
```js
mXComponentController: XComponentController = new XComponentController // Create an XComponentController.
build() {
Flex() {
XComponent({ // Create an XComponent.
id: '',
type: 'surface',
libraryname: '',
controller: this.mXComponentController
})
.onload(() => { // Set the onload callback.
// Set the width and height of the surface to 1920 and 1080, respectively.
this.mXComponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080})
// Obtain the surface ID.
globalThis.surfaceId = mXComponentController.getXComponentSurfaceId()
})
.width('1920px') // Set the width of the XComponent.
.height('1080px') // Set the height of the XComponent.
}
}
```
# OpenSL ES Audio Recording Development
## When to Use
You can use OpenSL ES to develop the audio recording function in OpenHarmony. Currently, only some
[OpenSL ES APIs](https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h) are implemented. If an API that has not been implemented yet is called, **SL_RESULT_FEATURE_UNSUPPORTED** will be returned.
## How to Develop
To use OpenSL ES to develop the audio recording function in OpenHarmony, perform the following steps:
1. Add the header files.
```c++
#include <OpenSLES.h>
#include <OpenSLES_OpenHarmony.h>
#include <OpenSLES_Platform.h>
```
2. Use the **slCreateEngine** API to create and instantiate the **engine** instance.
```c++
SLObjectItf engineObject = nullptr;
slCreateEngine(&engineObject, 0, nullptr, 0, nullptr, nullptr);
(*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
```
3. Obtain the **engineEngine** instance of the **SL_IID_ENGINE** interface.
```c++
SLEngineItf engineItf = nullptr;
result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineItf);
```
4. Configure the recorder information (including the input source **audiosource** and output source **audiosink**), and create a **pcmCapturerObject** instance.
```c++
SLDataLocator_IODevice io_device = {
SL_DATALOCATOR_IODEVICE,
SL_IODEVICE_AUDIOINPUT,
SL_DEFAULTDEVICEID_AUDIOINPUT,
NULL
};
SLDataSource audioSource = {
&io_device,
NULL
};
SLDataLocator_BufferQueue buffer_queue = {
SL_DATALOCATOR_BUFFERQUEUE,
3
};
// Configure the parameters based on the audio file format.
SLDataFormat_PCM format_pcm = {
SL_DATAFORMAT_PCM,
OHOS::AudioStandard::AudioChannel::MONO,
OHOS::AudioStandard::AudioSamplingRate::SAMPLE_RATE_44100,
OHOS::AudioStandard::AudioSampleFormat::SAMPLE_S16LE,
0,
0,
0
};
SLDataSink audioSink = {
&buffer_queue,
&format_pcm
};
SLObjectItf pcmCapturerObject = nullptr;
result = (*engineItf)->CreateAudioRecorder(engineItf, &pcmCapturerObject,
&audioSource, &audioSink, 0, nullptr, nullptr);
(*pcmCapturerObject)->Realize(pcmCapturerObject, SL_BOOLEAN_FALSE);
```
5. Obtain the **recordItf** instance of the **SL_IID_RECORD** interface.
```
SLRecordItf recordItf;
(*pcmCapturerObject)->GetInterface(pcmCapturerObject, SL_IID_RECORD, &recordItf);
```
6. Obtain the **bufferQueueItf** instance of the **SL_IID_OH_BUFFERQUEUE** interface.
```
SLOHBufferQueueItf bufferQueueItf;
(*pcmCapturerObject)->GetInterface(pcmCapturerObject, SL_IID_OH_BUFFERQUEUE, &bufferQueueItf);
```
7. Register the **BufferQueueCallback** function.
```c++
static void BufferQueueCallback(SLOHBufferQueueItf bufferQueueItf, void *pContext, SLuint32 size)
{
AUDIO_INFO_LOG("BufferQueueCallback");
FILE *wavFile = (FILE *)pContext;
if (wavFile != nullptr) {
SLuint8 *buffer = nullptr;
SLuint32 pSize = 0;
(*bufferQueueItf)->GetBuffer(bufferQueueItf, &buffer, pSize);
if (buffer != nullptr) {
fwrite(buffer, 1, pSize, wavFile);
(*bufferQueueItf)->Enqueue(bufferQueueItf, buffer, size);
}
}
return;
}
// Set wavFile_ to the descriptor of the file to be recorded.
(*bufferQueueItf)->RegisterCallback(bufferQueueItf, BufferQueueCallback, wavFile_);
```
8. Start audio recording.
```c++
static void CaptureStart(SLRecordItf recordItf, SLOHBufferQueueItf bufferQueueItf, FILE *wavFile)
{
AUDIO_INFO_LOG("CaptureStart");
(*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_RECORDING);
if (wavFile != nullptr) {
SLuint8* buffer = nullptr;
SLuint32 pSize = 0;
(*bufferQueueItf)->GetBuffer(bufferQueueItf, &buffer, pSize);
if (buffer != nullptr) {
AUDIO_INFO_LOG("CaptureStart, enqueue buffer length: %{public}lu.", pSize);
fwrite(buffer, 1, pSize, wavFile);
(*bufferQueueItf)->Enqueue(bufferQueueItf, buffer, pSize);
} else {
AUDIO_INFO_LOG("CaptureStart, buffer is null or pSize: %{public}lu.", pSize);
}
}
return;
}
```
9. Stop audio recording.
```c++
static void CaptureStop(SLRecordItf recordItf)
{
AUDIO_INFO_LOG("Enter CaptureStop");
fflush(wavFile_);
(*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_STOPPED);
(*pcmCapturerObject)->Destroy(pcmCapturerObject);
fclose(wavFile_);
wavFile_ = nullptr;
return;
}
```
# Common Event and Notification
- [Common Event and Notification Overview](notification-brief.md)
- Common Event
- [Common Event Development](common-event.md)
- Notification
- [Notification Development](notification.md)
- Debugging Tools
- [Debugging Assistant Usage](assistant-guidelines.md)
- [Common Event Development](common-event.md)
- [Notification Development](notification.md)
- [Debugging Assistant Usage](assistant-guidelines.md)
......@@ -9,7 +9,7 @@ Example of the **resources** directory:
```
resources
|---base // Default directory
|---base // Default sub-directory
| |---element
| | |---string.json
| |---media
......@@ -19,7 +19,7 @@ resources
| | |---string.json
| |---media
| | |---icon.png
|---rawfile // Default directory
|---rawfile // Default sub-directory
```
**Table 1** Categories of the **resources** directory
......
......@@ -2,7 +2,7 @@
DevEco Studio is a one-stop, distributed platform developed based on the IntelliJ IDEA Community (Open Source) Edition. It helps you develop versatile all-device, all-scenario applications, offering distributed multi-device development, debugging, and simulation, as well as comprehensive quality and security safeguards.
HUAWEI DevEco Studio For OpenHarmony (DevEco Studio for short) is a one-stop, distributed platform developed based on the IntelliJ IDEA Community (Open Source) Edition. It helps you develop versatile all-device, all-scenario applications, offering distributed multi-device development, debugging, and simulation, as well as comprehensive quality and security safeguards.
[DevEco Studio 3.0 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) stands out in the following aspects:
......@@ -12,8 +12,8 @@ DevEco Studio is a one-stop, distributed platform developed based on the Intelli
- Visualized UI development
- Bidirectional and instant UI preview
- High-performing compilation tool Hvigor
- Support for application development based on the device Syscap capability set
- Automatic application signature mechanism
- Support for application development based on the device System Capability (SysCap) sets
- Automatic application signing mechanism
- A diverse array of code debugging and profiling features
For more information, see [DevEco Studio (OpenHarmony) User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421).
For more information, see [HUAWEI DevEco Studio For OpenHarmony User Guide](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-deveco-studio-overview-0000001263280421).
en/application-dev/quick-start/figures/image-20220326065124911.png

181.2 KB | W: 0px | H: 0px

en/application-dev/quick-start/figures/image-20220326065124911.png

181.1 KB | W: 0px | H: 0px

en/application-dev/quick-start/figures/image-20220326065124911.png
en/application-dev/quick-start/figures/image-20220326065124911.png
en/application-dev/quick-start/figures/image-20220326065124911.png
en/application-dev/quick-start/figures/image-20220326065124911.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -276,7 +276,7 @@ Table 12 Internal structure of the distro attribute
| moduleName | Name of the current HAP file. The maximum length is 31 characters. | String | No |
| moduleType | Type of the current HAP file. The value can be **entry** or **feature**. For the HAR type, set this attribute to **har**. | String | No |
| installationFree | Whether the HAP file supports the installation-free feature.<br> **true**: The HAP file supports the installation-free feature and meets installation-free constraints.<br> **false**: The HAP file does not support the installation-free feature.<br> Pay attention to the following:<br> When **entry.hap** is set to **true**, all **feature.hap** fields related to **entry.hap **must be **true**.<br> When **entry.hap** is set to **false**, **feature.hap** related to **entry.hap** can be set to **true** or **false** based on service requirements. | Boolean | No |
| deliveryWithInstall | Whether the HAP file supports the installation with application<br /> true: Support。<br /> false:No Support。 | Boolean | No |
| deliveryWithInstall | Whether the HAP file supports the installation with application.<br /> **true**: The HAP file supports the installation with application.<br /> **false**: The HAP file does not support the installation with application. | Boolean | No |
Example of the **distro** attribute structure:
......
......@@ -124,6 +124,7 @@
- [@ohos.statfs](js-apis-statfs.md)
- [@ohos.storageStatistics](js-apis-storage-statistics.md)
- [@ohos.volumeManager](js-apis-volumemanager.md)
- [@ohos.securityLabel](js-apis-securityLabel.md)
- Telephony Service
......
# DataUriUtils Module
> **NOTE**<br>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......@@ -19,20 +19,20 @@ Obtains the ID attached to the end of a given URI.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object from which the ID is to be obtained. |
| uri | string | Yes | URI object from which the ID is to be obtained.|
**Return value**
| Type | Description |
| Type | Description |
| ------ | ------------------------ |
| number | ID obtained from the URI object. |
| number | ID obtained from the URI object.|
**Example**
```js
dataUriUtils.getIdSync("com.example.dataUriUtils/1221")
dataUriUtils.getId("com.example.dataUriUtils/1221")
```
......@@ -47,16 +47,16 @@ Attaches an ID to the end of a given URI.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object to which an ID is to be attached. |
| id | number | Yes | ID to be attached. |
| uri | string | Yes | URI object to which an ID is to be attached.|
| id | number | Yes | ID to be attached. |
**Return value**
| Type | Description |
| Type | Description |
| ------ | --------------------- |
| string | URI object with the ID attached. |
| string | URI object with the ID attached.|
**Example**
......@@ -80,15 +80,15 @@ Deletes the ID from the end of a given URI.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object from which the ID is to be deleted. |
| uri | string | Yes | URI object from which the ID is to be deleted.|
**Return value**
| Type | Description |
| Type | Description |
| ------ | ------------------- |
| string | URI object with the ID deleted. |
| string | URI object with the ID deleted.|
**Example**
......@@ -108,16 +108,16 @@ Updates the ID in a given URI.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------- |
| uri | string | Yes | URI object to be updated. |
| id | number | Yes | New ID. |
| uri | string | Yes | URI object to be updated.|
| id | number | Yes | New ID. |
**Return value**
| Type | Description |
| Type | Description |
| ------ | --------------- |
| string | URI object with the new ID. |
| string | URI object with the new ID.|
**Example**
......
# AbilityContext
> **NOTE**<br>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the ability context. This module is inherited from **Context**.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Usage
Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**.
```js
import Ability from '@ohos.application.Ability'
class MainAbility extends Ability {
......@@ -28,7 +28,7 @@ class MainAbility extends Ability {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| abilityInfo | AbilityInfo | Yes| No| Ability information.|
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.|
......@@ -44,7 +44,7 @@ Starts an ability. This API uses a callback to return the result.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
......@@ -73,7 +73,7 @@ Starts an ability. This API uses a callback to return the result.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
......@@ -106,14 +106,14 @@ Starts an ability. This API uses a promise to return the result.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
......@@ -147,7 +147,7 @@ Starts an ability. This API uses a callback to return the execution result when
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.|
......@@ -157,7 +157,7 @@ Starts an ability. This API uses a callback to return the execution result when
```js
this.context.startAbilityForResult(
{bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"},
{deviceId: "", bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"},
(error, result) => {
console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code)
console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode)
......@@ -175,7 +175,7 @@ Starts an ability. This API uses a callback to return the execution result when
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
......@@ -189,7 +189,7 @@ Starts an ability. This API uses a callback to return the execution result when
windowMode: 0,
};
this.context.startAbilityForResult(
{bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options,
{deviceId: "", bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options,
(error, result) => {
console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code)
console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode)
......@@ -208,7 +208,7 @@ Starts an ability. This API uses a promise to return the execution result when t
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.|
......@@ -216,7 +216,7 @@ Starts an ability. This API uses a promise to return the execution result when t
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Promise used to return the result.|
......@@ -226,7 +226,7 @@ Starts an ability. This API uses a promise to return the execution result when t
var options = {
windowMode: 0,
};
this.context.startAbilityForResult({bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options).then((result) => {
this.context.startAbilityForResult({deviceId: "", bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options).then((result) => {
console.log("startAbilityForResult Promise.resolve is called, result.resultCode = " + result.resultCode)
}, (error) => {
console.log("startAbilityForResult Promise.Reject is called, error.code = " + error.code)
......@@ -244,7 +244,7 @@ Terminates this ability. This API uses a callback to return the result.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
......@@ -267,7 +267,7 @@ Terminates this ability. This API uses a promise to return the result.
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
......@@ -292,7 +292,7 @@ Terminates this ability. This API uses a callback to return the information to t
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
......@@ -321,13 +321,13 @@ Terminates this ability. This API uses a promise to return information to the ca
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
......@@ -355,13 +355,13 @@ Obtains the caller interface of the specified ability, and if the specified abil
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;Caller&gt; | Promise used to return the caller object to communicate with.|
......@@ -378,7 +378,7 @@ Obtains the caller interface of the specified ability, and if the specified abil
deviceId: ""
}).then((obj) => {
caller = obj;
console.log('Caller GetCaller Get ' + call);
console.log('Caller GetCaller Get ' + caller);
}).catch((e) => {
console.log('Caller GetCaller error ' + e);
});
......@@ -397,17 +397,19 @@ Requests permissions from the user by displaying a pop-up window. This API uses
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| Permissions to request.|
| callback | AsyncCallback&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
**Example**
```
this.context.requestPermissionsFromUser(permissions,(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
```js
var permissions=['com.example.permission']
this.context.requestPermissionsFromUser(permissions,(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
});
```
......@@ -421,24 +423,26 @@ Requests permissions from the user by displaying a pop-up window. This API uses
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| Permissions to request.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example**
```
this.context.requestPermissionsFromUser(permissions).then((data) => {
```js
var permissions=['com.example.permission']
this.context.requestPermissionsFromUser(permissions).then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -452,7 +456,7 @@ Sets the label of the ability displayed in the task. This API uses a callback to
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
......@@ -476,13 +480,13 @@ Sets the label of the ability displayed in the task. This API uses a promise to
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
......
# Ability Access Control
# Ability Access Control
> **NOTE**<br>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......@@ -20,9 +20,9 @@ Creates an **AtManager** instance, which is used for ability access control.
**Return value**
| Type | Description |
| -------- | -------- |
| [AtManager](#atmanager) | **AtManager** instance obtained. |
| Type| Description|
| -------- | -------- |
| [AtManager](#atmanager) | **AtManager** instance obtained.|
**Example**
......@@ -44,16 +44,16 @@ Checks whether an application has been granted the specified permission. This AP
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to verify. |
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to verify.|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;GrantStatus&gt; | Promise used to return the result. |
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;GrantStatus&gt; | Promise instance used to return the result.|
**Example**
......@@ -78,24 +78,25 @@ Grants a user granted permission to an application. This API uses a promise to r
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant. |
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the result. |
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise instance used to return the result.|
**Example**
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
let permissionFlag = 1;
let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag);
promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
});
......@@ -115,12 +116,12 @@ Grants a user granted permission to an application. This API uses an asynchronou
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant. |
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. |
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -145,17 +146,17 @@ Revokes a user granted permission given to an application. This API uses a promi
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke. |
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the result. |
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise instance used to return the result.|
**Example**
......@@ -181,18 +182,19 @@ Revokes a user granted permission given to an application. This API uses an asyn
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke. |
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. |
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result.|
**Example**
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let permissionFlag = 1;
AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
......@@ -210,16 +212,16 @@ Obtains the flags of the specified permission of a given application. This API u
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to query. |
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to query.|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the result. |
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise instance used to return the result.|
**Example**
......@@ -238,7 +240,7 @@ Enumerates the permission grant states.
**System capability**: SystemCapability.Security.AccessToken
| Name | Default Value | Description |
| ----------------------------- | ---------------------- | ----------------------- |
| PERMISSION_DENIED | -1 | Permission denied. |
| PERMISSION_GRANTED | 0 | Permission granted. |
| Name | Default Value | Description |
| ----------------------------- | ---------------------- | ----------------------- |
| PERMISSION_DENIED | -1 | Permission denied. |
| PERMISSION_GRANTED | 0 | Permission granted. |
......@@ -6,7 +6,11 @@
Provides ability running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
## Usage
......@@ -25,14 +29,14 @@ abilitymanager.getAbilityRunningInfos((err,data) => {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes | No | Information that matches an ability. |
| pid | number | Yes | No | Process ID. |
| uid | number | Yes | No | User ID. |
| processName | string | Yes | No | Process name. |
| startTime | number | Yes | No | Ability start time. |
| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes | No | Ability state. |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes| No| Information that matches an ability. |
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID. |
| processName | string | Yes| No| Process name. |
| startTime | number | Yes| No| Ability start time. |
| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes| No| Ability state. |
## abilityManager.AbilityState
......@@ -41,10 +45,10 @@ Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state. |
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
| Name| Value| Description|
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
......@@ -6,6 +6,11 @@
Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md).
## Modules to Import
```js
import AbilityStage from '@ohos.application.AbilityStage';
```
## Usage
......@@ -28,7 +33,7 @@ class MyAbilityStage extends AbilityStage {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type | Readable | Writable | Description |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes | No | **ModuleInfo** object corresponding to the **AbilityStage**. |
| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running. |
| currentHapModuleInfo | HapModuleInfo | Yes| No| **ModuleInfo** object corresponding to the **AbilityStage**.|
| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running.|
# MissionSnapshot
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the snapshot of a mission.
## Modules to Import
```
import { ElementName } from '../bundle/elementName';
import { image } from '../@ohos.multimedia.image';
import abilitymanager from '@ohos.application.abilityManager';
import ElementName from '@ohos.bundle';
import image from '@ohos.multimedia.image';
```
## MissionSnapshot
Describes the mission snapshot.
| Name | Type | Readable | Writable | Description |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes | Yes | Information that matches an ability. |
| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission. |
| ability | ElementName | Yes| Yes| Information that matches an ability.|
| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission.|
......@@ -3,13 +3,10 @@
> **NOTE**<br>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Manages the ability lifecycle and context.
## Modules to Import
```
import Ability from '@ohos.application.Ability';
```
......@@ -18,11 +15,11 @@ import Ability from '@ohos.application.Ability';
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
| context | [AbilityContext](js-apis-ability-context.md) | Yes | No | Context of an ability. |
| launchWant | [Want](js-apis-application-Want.md) | Yes | No | Parameters for starting the ability. |
| lastRequestWant | [Want](js-apis-application-Want.md) | Yes | No | Parameters used when the ability was started last time. |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.|
| launchWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters for starting the ability.|
| lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.|
## Ability.onCreate
......@@ -35,10 +32,10 @@ Called to initialize the service logic when an ability is created.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes | Information related to this ability, including the ability name and bundle name. |
| param | AbilityConstant.LaunchParam | Yes | Parameters for starting the ability, and the reason for the last abnormal exit. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
| param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
**Example**
......@@ -61,9 +58,9 @@ Called when a **WindowStage** is created for this ability.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes | **WindowStage** information. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example**
......@@ -105,9 +102,9 @@ Called when the **WindowStage** is restored during the migration of this ability
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes | **WindowStage** information. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example**
......@@ -143,7 +140,7 @@ Called when this ability is destroyed to clear resources.
onForeground(): void;
Called when this ability is running in the foreground.
Called when this ability is switched from the background to the foreground.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
......@@ -162,7 +159,7 @@ Called when this ability is running in the foreground.
onBackground(): void;
Callback when this ability is switched to the background.
Called when this ability is switched from the foreground to the background.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
......@@ -187,24 +184,25 @@ Called to save data during the ability migration preparation process.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes | **want** parameter. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
**Return value**
| Type | Description |
| -------- | -------- |
| AbilityConstant.OnContinueResult | Continuation result. |
| Type| Description|
| -------- | -------- |
| AbilityConstant.OnContinueResult | Continuation result.|
**Example**
```js
import AbilityConstant from "@ohos.application.AbilityConstant"
class myAbility extends Ability {
onContinue(wantParams) {
console.log('onContinue');
wantParams["myData"] = "my1234567";
return true;
return AbilityConstant.OnContinueResult.AGREE;
}
}
```
......@@ -220,9 +218,9 @@ Called when the ability startup mode is set to singleton.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes | Want parameters, such as the ability name and bundle name. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
**Example**
......@@ -245,9 +243,9 @@ Called when the configuration of the environment where the ability is running is
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes | New configuration. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example**
......@@ -259,6 +257,32 @@ Called when the configuration of the environment where the ability is running is
}
```
## Ability.dump
dump(params: Array\<string>): Array\<string>;
Called when the client information is dumped.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| params | Array\<string> | Yes| Parameters in the form of a command.|
**Example**
```js
class myAbility extends Ability {
dump(params) {
console.log('dump, params:' + JSON.stringify(params));
return ["params"]
}
}
```
## Caller
......@@ -275,22 +299,25 @@ Sends sequenceable data to the target ability.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. |
| data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
**Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return a response. |
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return a response.|
**Example**
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{ // Custom sequenceable data structure
name:""
str:""
num: 1
constructor(name, str) {
this.name = name;
this.str = str;
......@@ -345,22 +372,25 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. |
| data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
**Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability. |
| Type| Description|
| -------- | -------- |
| Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability.|
**Example**
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
name:""
str:""
num: 1
constructor(name, str) {
this.name = name;
this.str = str;
......@@ -451,9 +481,9 @@ Registers a callback that is invoked when the Stub on the target ability is disc
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | OnReleaseCallBack | Yes | Callback used for the **onRelease** API. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
**Example**
......@@ -486,7 +516,7 @@ Registers a callback that is invoked when the Stub on the target ability is disc
## Callee
Implements callbacks for caller notification registration and unregistration.
Implements callbacks for caller notification registration and deregistration.
## Callee.on
......@@ -499,16 +529,19 @@ Registers a caller notification callback, which is invoked when the target abili
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| method | string | Yes | Notification message string negotiated between the two abilities. |
| callback | CaleeCallBack | Yes | JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.|
| callback | CaleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.|
**Example**
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
name:""
str:""
num: 1
constructor(name, str) {
this.name = name;
this.str = str;
......@@ -546,15 +579,15 @@ Registers a caller notification callback, which is invoked when the target abili
off(method: string): void;
Unregisters a caller notification callback, which is invoked when the target ability registers a function.
Deregisters a caller notification callback, which is invoked when the target ability registers a function.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| method | string | Yes | Registered notification message string. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Registered notification message string.|
**Example**
......@@ -575,9 +608,9 @@ Unregisters a caller notification callback, which is invoked when the target abi
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
| (msg: string) | function | Yes | No | Prototype of the listener function interface registered by the caller. |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| (msg: string) | function | Yes| No| Prototype of the listener function interface registered by the caller.|
## CaleeCallBack
......@@ -586,6 +619,6 @@ Unregisters a caller notification callback, which is invoked when the target abi
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes | No | Prototype of the message listener function interface registered by the callee. |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the message listener function interface registered by the callee.|
......@@ -185,7 +185,7 @@ Waits for the ability that matches the **AbilityMonitor** instance to reach the
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | Yes | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) instance.|
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the ability. |
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the result. |
**Example**
......@@ -223,7 +223,7 @@ Waits a period of time for the ability that matches the **AbilityMonitor** insta
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | Yes | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) instance.|
| timeout | number | Yes | Maximum waiting time, in milliseconds. |
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the ability. |
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the result. |
**Example**
......@@ -365,7 +365,7 @@ Obtains the top ability of the application. This API uses an asynchronous callba
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------ |
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the top ability.|
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the result.|
**Example**
......@@ -747,7 +747,7 @@ abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => {
### executeShellCommand
executeShellCommand(cmd: string, timeoutSecs: number): Promise\<ShellCmdResult>
executeShellCommand(cmd: string, timeoutSecs?: number): Promise\<ShellCmdResult>
Executes a shell command with the timeout period specified. This API uses a promise to return the result.
......
# AbilityDelegatorArgs
> **NOTE**
> **NOTE**<br/>
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# Context
> **NOTE**<br>
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the context for running code, including **applicationInfo** and **resourceManager**.
## Modules to Import
```
import AbilityContext from '@ohos.application.Ability';
```
## Usage
You must extend **AbilityContext** to implement this module.
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
| resourceManager | ResourceManager | Yes | No | **ResourceManager** object. |
| applicationInfo | ApplicationInfo | Yes | No | Information about the application. |
| cacheDir | string | Yes | No | Cache directory of the application on the internal storage. |
| tempDir | string | Yes | No | Temporary file directory of the application. |
| filesDir | string | Yes | No | File directory of the application on the internal storage. |
| databaseDir | string | Yes | No | Storage directory of local data. |
| storageDir | string | Yes | No | Storage directory of lightweight data. |
| bundleCodeDir | string | Yes | No | Application installation path. |
| distributedFilesDir | string | Yes | No | Storage directory of distributed application data files. |
| eventHub | [EventHub](js-apis-eventhub.md) | Yes | No | Event hub information. |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| resourceManager | ResourceManager | Yes| No| **ResourceManager** object.|
| applicationInfo | ApplicationInfo | Yes| No| Information about the application.|
| cacheDir | string | Yes| No| Cache directory of the application on the internal storage.|
| tempDir | string | Yes| No| Temporary file directory of the application.|
| filesDir | string | Yes| No| File directory of the application on the internal storage.|
| databaseDir | string | Yes| No| Storage directory of local data.|
| storageDir | string | Yes| No| Storage directory of lightweight data.|
| bundleCodeDir | string | Yes| No| Application installation path.|
| distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.|
| eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.|
| area | [AreaMode](#areamode) | Yes| Yes| Area in which the file to be access is located.|
## Context.createBundleContext
......@@ -41,27 +44,33 @@ Creates an application context.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes | Application bundle name. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
**Return value**
| Type | Description |
| -------- | -------- |
| Context | Context of the application created. |
| Type| Description|
| -------- | -------- |
| Context | Context of the application created.|
**Example**
```js
let test = "com.example.test";
let context = this.context.createBundleContext(test);
import AbilityContext from '@ohos.application.Ability'
class MainAbility extends AbilityContext {
onWindowStageCreate(windowStage) {
let test = "com.example.test";
let context = this.context.createBundleContext(test);
}
}
```
## Context.getApplicationContext
getApplicationContext(): Context;
getApplicationContext(): ApplicationContext;
Obtains the context of this application.
......@@ -69,13 +78,25 @@ Obtains the context of this application.
**Return value**
| Type | Description |
| -------- | -------- |
| Context | Context obtained. |
| Type| Description|
| -------- | -------- |
| ApplicationContext | Current application context.|
**Example**
```js
// This part is mandatory.
let context = this.context.getApplicationContext();
let applicationContext = this.context.getApplicationContext();
```
## AreaMode
Defines the area where the file to be access is located. Each area has its own content.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| --------------- | ---- | --------------- |
| EL1 | 0 | Device-level encryption area. |
| EL2 | 1 | User credential encryption area. The default value is **EL2**.|
# MissionInfo
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import MissionInfo from '@ohos.application.missionInfo'
```
## MissionInfo
Provides the mission information.
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| missionId | number | Yes| Yes| Mission ID.|
| runningState | number | Yes| Yes| Running state of the mission.|
| lockedState | boolean | Yes| Yes| Locked state of the mission.|
| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
| want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.|
| label | string | Yes| Yes| Label of the mission.|
| iconPath | string | Yes| Yes| Path of the mission icon.|
| continuable | boolean | Yes| Yes| Whether the mission is continuable.|
# ShellCmdResult
> **NOTE**
> **NOTE**<br>
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# appManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -34,7 +34,7 @@ Checks whether this application is undergoing a stability test. This API uses an
```js
import app from '@ohos.application.appManager';
app.isRunningInStabilityTest((err, flag) => {
console.log('startAbility result:' + JSON.stringfy(err));
console.log('startAbility result:' + JSON.stringify(err));
})
```
......@@ -58,9 +58,9 @@ Checks whether this application is undergoing a stability test. This API uses a
```js
import app from '@ohos.application.appManager';
app.isRunningInStabilityTest().then((flag) => {
console.log('success:' + JSON.stringfy(flag));
console.log('success:' + JSON.stringify(flag));
}).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -82,7 +82,7 @@ Checks whether this application is running on a RAM constrained device. This API
**Example**
```js
app.isRamConstrainedDevicePromise().then((data) => {
app.isRamConstrainedDevice().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
......@@ -106,7 +106,7 @@ Checks whether this application is running on a RAM constrained device. This API
**Example**
```js
app.isRamConstrainedDevicePromise((err, data) => {
app.isRamConstrainedDevice((err, data) => {
console.log('startAbility result failed:' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
......@@ -160,7 +160,7 @@ Obtains the memory size of this application. This API uses an asynchronous callb
```
## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(): Promise<Array<ProcessRunningInfo>>;
getProcessRunningInfos(): Promise<Array\<ProcessRunningInfo>>;
Obtains information about the running processes. This API uses a promise to return the result.
......@@ -175,7 +175,7 @@ Obtains information about the running processes. This API uses a promise to retu
**Example**
```js
app.GetProcessRunningInfos().then((data) => {
app.getProcessRunningInfos().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
......@@ -184,7 +184,7 @@ Obtains information about the running processes. This API uses a promise to retu
## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(callback: AsyncCallback<Array<ProcessRunningInfo>>): void;
getProcessRunningInfos(callback: AsyncCallback<Array\<ProcessRunningInfo>>): void;
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
......@@ -199,7 +199,7 @@ Obtains information about the running processes. This API uses an asynchronous c
**Example**
```js
app.GetProcessRunningInfos((err, data) => {
app.getProcessRunningInfos((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
......
# DataAbilityHelper Module (JavaScript SDK APIs)
> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE**
> **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import featureAbility from "@ohos.ability.featureAbility";
```
## Usage
Import the following modules based on the actual situation before using the current module:
```
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
import ohos_data_ability from '@ohos.data.dataAbility'
import ohos_data_rdb from '@ohos.data.rdb'
```
......@@ -499,7 +506,7 @@ const valueBucket = {
"name": "rose",
"age": 22,
"salary": 200.5,
"blobType": u8,
"blobType": "u8",
}
DAHelper.insert(
"dataability:///com.example.DataAbility",
......@@ -541,7 +548,7 @@ const valueBucket = {
"name": "rose1",
"age": 221,
"salary": 20.5,
"blobType": u8,
"blobType": "u8",
}
DAHelper.insert(
"dataability:///com.example.DataAbility",
......@@ -574,9 +581,9 @@ import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,},
{"name": "roe12", "age": 21, "salary": 20.5, "blobType": u8,},
{"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,})
var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": "u8",},
{"name": "roe12", "age": 21, "salary": 20.5, "blobType": "u8",},
{"name": "roe13", "age": 21, "salary": 20.5, "blobType": "u8",})
DAHelper.batchInsert(
"dataability:///com.example.DataAbility",
cars,
......@@ -613,9 +620,9 @@ import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,},
{"name": "roe12", "age": 21, "salary": 20.5, "blobType": u8,},
{"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,})
var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": "u8",},
{"name": "roe12", "age": 21, "salary": 20.5, "blobType": "u8",},
{"name": "roe13", "age": 21, "salary": 20.5, "blobType": "u8",})
DAHelper.batchInsert(
"dataability:///com.example.DataAbility",
cars
......@@ -682,6 +689,7 @@ Deletes one or more data records from the database. This API uses a promise to r
```js
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
......@@ -723,7 +731,7 @@ const va = {
"name": "roe1",
"age": 21,
"salary": 20.5,
"blobType": u8,
"blobType": "u8",
}
let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.update(
......@@ -769,7 +777,7 @@ const va = {
"name": "roe1",
"age": 21,
"salary": 20.5,
"blobType": u8,
"blobType": "u8",
}
let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.update(
......
......@@ -3,6 +3,7 @@
> **NOTE**<br>
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module will be deprecated and are not recommended for use. An exception will be thrown if any of the APIs is called.
## Modules to Import
```js
......@@ -19,15 +20,15 @@ Chooses a file of the specified type using the file manager. This API uses a pro
- Parameters
| Name| Type | Mandatory | Description |
| ------ | ------ | ---- | ---------------------------- |
| type | string[] | No | Type of the file to choose. |
| Name| Type | Mandatory | Description |
| ------ | ------ | ---- | ---------------------------- |
| type | string[] | No | Type of the file to choose. |
- Return value
| Type | Description |
| --------------------- | -------------- |
| Promise&lt;string&gt; | Promise used to return the result. An error code is returned. |
| Type | Description |
| --------------------- | -------------- |
| Promise&lt;string&gt; | Promise used to return the result. An error code is returned. |
- Example
......@@ -44,9 +45,9 @@ Chooses a file using the file manager. This API uses an asynchronous callback to
- Parameters
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. |
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. |
- Example
......@@ -65,10 +66,10 @@ Chooses a file of the specified type using the file manager. This API uses an as
- Parameters
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| type | string[] | No | Type of the file to choose. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. |
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| type | string[] | No | Type of the file to choose. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. An error code is returned. |
- Example
......@@ -88,16 +89,16 @@ Opens a file. This API uses a promise to return the result.
- Parameters
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------- |
| uri | string | Yes | URI of the file to open. |
| type | string | Yes | Type of the file to open. |
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------- |
| uri | string | Yes | URI of the file to open. |
| type | string | Yes | Type of the file to open. |
- Return value
| Type | Description |
| --------------------- | ------------ |
| Promise&lt;void&gt; | Promise used to return the result. An error code is returned. |
| Type | Description |
| --------------------- | ------------ |
| Promise&lt;void&gt; | Promise used to return the result. An error code is returned. |
- Example
......@@ -115,11 +116,11 @@ Opens a file. This API uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| uri | string | Yes | URI of the file to open. |
| type | string | Yes | Type of the file to open. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. An error code is returned. |
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | ---------------------------- |
| uri | string | Yes | URI of the file to open. |
| type | string | Yes | Type of the file to open. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. An error code is returned. |
- Example
......
# EventHub
> **NOTE**<br>
> **NOTE**<br/>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements event subscription, unsubscription, and triggering.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Usage
Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
```js
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
func1(){
console.log("func1 is called");
}
onForeground() {
this.context.eventHub.on("123", this.func1);
}
......@@ -34,10 +42,10 @@ Subscribes to an event.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. |
| callback | Function | Yes | Callback invoked when the event is triggered. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | Yes| Callback invoked when the event is triggered.|
**Example**
......@@ -72,10 +80,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. |
| callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | No| Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed.|
**Example**
......@@ -110,10 +118,10 @@ Triggers an event.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. |
| ...args | Object[] | Yes | Variable parameters, which are passed to the callback when the event is triggered. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered.|
**Example**
......
# ExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
```js
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility';
```
Implements the extension context. This module is inherited from **Context**.
......@@ -11,7 +15,7 @@ Implements the extension context. This module is inherited from **Context**.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes| No | Information about the current HAP. |
| config | Configuration | Yes| No | Module configuration information. |
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. |
| config | Configuration | Yes| No| Module configuration information.|
# ExtensionRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides extension running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
## Usage
......@@ -14,8 +19,9 @@ The extension running information is obtained through an **abilityManager** inst
```
```js
import abilitymanager from '@ohos.application.abilityManager';
let upperLimit=1
abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => {
console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
......
# FormExtension
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides **FormExtension** APIs.
......@@ -46,6 +46,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been
**Example**
```js
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onCreate(want) {
console.log('FormExtension onCreate, want:' + want.abilityName);
......@@ -100,6 +101,7 @@ Called to notify the widget provider that a widget has been updated. After obtai
**Example**
```js
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onUpdate(formId) {
console.log('FormExtension onUpdate, formId:' + formId);
......@@ -130,6 +132,7 @@ Called to notify the widget provider of the change of visibility.
**Example**
```js
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onVisibilityChange(newStatus) {
console.log('FormExtension onVisibilityChange, newStatus:' + newStatus);
......@@ -213,9 +216,35 @@ Called when the configuration of the environment where the ability is running is
**Example**
```js
class MyFormExtension extends MyFormExtension {
class MyFormExtension extends FormExtension {
onConfigurationUpdated(config) {
console.log('onConfigurationUpdated, config:' + JSON.stringify(config));
}
}
```
## FormExtension.onAcquireFormState
onAcquireFormState?(want: Want): formInfo.FormState;
Used by the widget provider to receive the widget state query request. By default, the initial widget state is returned.
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | No| Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension.|
**Example**
```js
import fromInfo from '@ohos.application.fromInfo'
class MyFormExtension extends FormExtension {
onAcquireFormState(want) {
console.log('FormExtension onAcquireFormState, want:' + want);
return fromInfo.FormState.UNKNOWN;
}
}
```
# FormExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
## Modules to Import
```js
import FormExtension from '@ohos.application.FormExtension';
```
## FormExtensionContext.updateForm
updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void
......@@ -24,10 +30,18 @@ Updates a widget. This method uses a callback to return the result.
**Example**
```js
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2, (data)=>{
console.log('FormExtension context updateForm, data:' + data);
});
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onUpdate(formId) {
console.log('FormExtension onUpdate, formId:' + formId);
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2, (data)=>{
console.log('FormExtension context updateForm, data:' + data);
});
}
}
```
## FormExtensionContext.updateForm
......@@ -53,11 +67,18 @@ Updates a widget. This method uses a promise to return the result.
**Example**
```
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2)
.then((data)=>{
console.log('FormExtension context updateForm, data:' + data);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);});
```js
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onUpdate(formId) {
console.log('FormExtension onUpdate, formId:' + formId);
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2)
.then((data)=>{
console.log('FormExtension context updateForm, data:' + data);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);});
}
}
```
# FormHost
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to the widget host.
......@@ -311,7 +311,7 @@ SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
var formId = ["12400633174999288"];
formHost.notifyVisibleForms(formId, (error, data) => {
if (error.code) {
console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
......@@ -344,7 +344,7 @@ SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
var formId = ["12400633174999288"];
formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success');
}).catch((error) => {
......@@ -372,7 +372,7 @@ SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
var formId = ["12400633174999288"];
formHost.notifyInvisibleForms(formId, (error, data) => {
if (error.code) {
console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
......@@ -405,7 +405,7 @@ SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
var formId = ["12400633174999288"];
formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success');
}).catch((error) => {
......@@ -433,7 +433,7 @@ SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
var formId = ["12400633174999288"];
formHost.enableFormsUpdate(formId, (error, data) => {
if (error.code) {
console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
......@@ -466,7 +466,7 @@ SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
var formId = ["12400633174999288"];
formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success');
}).catch((error) => {
......@@ -494,7 +494,7 @@ SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
var formId = ["12400633174999288"];
formHost.disableFormsUpdate(formId, (error, data) => {
if (error.code) {
console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
......@@ -527,7 +527,7 @@ SystemCapability.Ability.Form
**Example**
```js
var formId = "12400633174999288";
var formId = ["12400633174999288"];
formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success');
}).catch((error) => {
......@@ -591,7 +591,7 @@ SystemCapability.Ability.Form
## getAllFormsInfo
getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;FormInfo&gt;&gt;): void;
getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void;
Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result.
......@@ -619,7 +619,8 @@ SystemCapability.Ability.Form
## getAllFormsInfo
getAllFormsInfo(): Promise&lt;Array&lt;FormInfo&gt;&gt;;
getAllFormsInfo(): Promise&lt;Array&lt;formInfo.FormInfo&gt;&gt;;
Obtains the widget information provided by all applications on the device. This API uses a promise to return the result.
......@@ -645,7 +646,8 @@ SystemCapability.Ability.Form
## getFormsInfo
getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;FormInfo&gt;&gt;): void;
getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void;
Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
......@@ -674,7 +676,8 @@ SystemCapability.Ability.Form
## getFormsInfo
getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt;Array&lt;FormInfo&gt;&gt;): void;
getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void;
Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
......@@ -704,7 +707,8 @@ SystemCapability.Ability.Form
## getFormsInfo
getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;FormInfo&gt;&gt;;
getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;formInfo.FormInfo&gt;&gt;;
Obtains the widget information provided by a given application on the device. This API uses a promise to return the result.
......@@ -767,7 +771,7 @@ SystemCapability.Ability.Form
## deleteInvalidForms
function deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt;;
deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt;;
Deletes invalid widgets from the list. This API uses a promise to return the result.
......@@ -800,7 +804,7 @@ SystemCapability.Ability.Form
## acquireFormState
acquireFormState(want: Want, callback: AsyncCallback&lt;FormStateInfo&gt;): void;
acquireFormState(want: Want, callback: AsyncCallback&lt;formInfo.FormStateInfo&gt;): void;
Obtains the widget state. This API uses an asynchronous callback to return the result.
......@@ -819,9 +823,14 @@ SystemCapability.Ability.Form
```js
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
"abilityName": "com.extreme.test.MainAbility"
"deviceId": "",
"bundleName": "ohos.samples.FormApplication",
"abilityName": "FormAbility",
"parameters": {
"ohos.extra.param.key.module_name": "entry",
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.form_dimension": 2
}
};
formHost.acquireFormState(want, (error, data) => {
if (error.code) {
......@@ -834,7 +843,7 @@ SystemCapability.Ability.Form
## acquireFormState
function acquireFormState(want: Want): Promise&lt;FormStateInfo&gt;;
acquireFormState(want: Want): Promise&lt;formInfo.FormStateInfo&gt;;
Obtains the widget state. This API uses a promise to return the result.
......@@ -858,9 +867,14 @@ SystemCapability.Ability.Form
```js
var want = {
"deviceId": "",
"bundleName": "com.extreme.test",
"abilityName": "com.extreme.test.MainAbility"
"deviceId": "",
"bundleName": "ohos.samples.FormApplication",
"abilityName": "FormAbility",
"parameters": {
"ohos.extra.param.key.module_name": "entry",
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.form_dimension": 2
}
};
formHost.acquireFormState(want).then((data) => {
console.log('formHost acquireFormState, data:' + JSON.stringify(data));
......
# FormProvider
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to the widget provider.
......@@ -38,8 +38,8 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error) {
console.log('formProvider setFormNextRefreshTime, error:' + error.code);
if (error.code) {
console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
}
});
```
......@@ -71,14 +71,16 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formProvider.setFormNextRefreshTime(formId, 5).catch((error) => {
formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log('formProvider setFormNextRefreshTime success');
}).catch((error) => {
console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
});
```
## updateForm
updateForm(formId: string, formBindingData: FormBindingData, callback: AsyncCallback&lt;void&gt;): void;
updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback&lt;void&gt;): void;
Updates a widget. This API uses an asynchronous callback to return the result.
......@@ -101,15 +103,15 @@ SystemCapability.Ability.Form
var formId = "12400633174999288";
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
formProvider.updateForm(formId, obj, (error, data) => {
if (error) {
console.log('formProvider updateForm, error:' + error.code);
if (error.code) {
console.log('formProvider updateForm, error:' + JSON.stringify(error));
}
});
```
## updateForm
updateForm(formId: string, formBindingData: FormBindingData): Promise&lt;void&gt;;
updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise&lt;void&gt;;
Updates a widget. This API uses a promise to return the result.
......@@ -136,7 +138,9 @@ SystemCapability.Ability.Form
import formBindingData from '@ohos.application.formBindingData';
var formId = "12400633174999288";
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
formProvider.updateForm(formId, obj).catch((error) => {
formProvider.updateForm(formId, obj).then(() => {
console.log('formProvider updateForm success');
}).catch((error) => {
console.log('formProvider updateForm, error:' + JSON.stringify(error));
});
```
# HiChecker
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
HiChecker is provided for you to check issues that may be easily ignored during development of OpenHarmony applications (including system-built and third-party applications). Such issues include calling of time-consuming functions by key application threads, event distribution and execution timeout in application processes, and ability resource leakage in application processes. The issues are recorded in logs or lead to process crashes explicitly so that you can find and rectify them.
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -11,7 +13,7 @@ import hichecker from '@ohos.hichecker';
```
## Constants
## Constant
Provides the constants of all rule types.
......@@ -19,16 +21,15 @@ Provides the constants of all rule types.
| Name | Type| Description |
| ---------------------------------- | -------- | ------------------------------------------------------ |
| RULE\_CAUTION\_PRINT\_LOG | BigInt | Alarm rule, which is programmed to print a log when an alarm is generated. |
| RULE\_CAUTION\_TRIGGER\_CRASH | BigInt | Alarm rule, which is programmed to force the application to exit when an alarm is generated. |
| RULE\_THREAD\_CHECK\_SLOW\_PROCESS | BigInt | Caution rule, which is programmed to detect whether any time-consuming function is invoked. |
| RULE\_CHECK\_SLOW\_EVENT | BigInt | Caution rule, which is programmed to detect whether the event distribution or processing time has exceeded the specified time threshold. |
| RULE\_CHECK\_ABILITY\_CONNECTION\_LEAK| BigInt | Caution rule, which is programmed to detect whether ability leakage has occurred. |
| RULE_CAUTION_PRINT_LOG | bigint | Alarm rule, which is programmed to print a log when an alarm is generated. |
| RULE_CAUTION_TRIGGER_CRASH | bigint | Alarm rule, which is programmed to force the application to exit when an alarm is generated. |
| RULE_THREAD_CHECK_SLOW_PROCESS | bigint | Caution rule, which is programmed to detect whether any time-consuming function is invoked. |
| RULE_CHECK_ABILITY_CONNECTION_LEAK | bigint | Caution rule, which is programmed to detect whether ability leakage has occurred. |
## hichecker.addRule
addRule(rule: BigInt): void
addRule(rule: bigint): void
Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules.
......@@ -36,9 +37,9 @@ Adds one or more rules. HiChecker detects unexpected operations or gives feedbac
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | BigInt | Yes | Rule to be added. |
| rule | bigint | Yes | Rule to be added.|
**Example**
......@@ -53,7 +54,7 @@ hichecker.addRule(
## hichecker.removeRule
removeRule(rule: BigInt): void
removeRule(rule: bigint): void
Removes one or more rules. The removed rules will become ineffective.
......@@ -61,9 +62,9 @@ Removes one or more rules. The removed rules will become ineffective.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | BigInt | Yes | Rule to be removed. |
| rule | bigint | Yes | Rule to be removed.|
**Example**
......@@ -78,7 +79,7 @@ hichecker.removeRule(
## hichecker.getRule
getRule(): BigInt
getRule(): bigint
Obtains a collection of thread, process, and alarm rules that have been added.
......@@ -88,7 +89,7 @@ Obtains a collection of thread, process, and alarm rules that have been added.
| Type | Description |
| ------ | ---------------------- |
| BigInt | Collection of added rules. |
| bigint | Collection of added rules.|
**Example**
......@@ -97,12 +98,12 @@ Obtains a collection of thread, process, and alarm rules that have been added.
hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS);
// Obtain the collection of added rules.
hichecker.getRule(); // Return 1n.
hichecker.getRule(); // return 1n;
```
## hichecker.contains
contains(rule: BigInt): boolean
contains(rule: bigint): boolean
Checks whether the specified rule exists in the collection of added rules. If the rule is of the thread level, this operation is performed only on the current thread.
......@@ -110,15 +111,15 @@ Checks whether the specified rule exists in the collection of added rules. If th
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- |
| rule | BigInt | Yes | Rule to be checked. |
| rule | bigint | Yes | Rule to be checked.|
**Return value**
| Type | Description |
| ------- | ---------------------------------------------------------- |
| boolean | Returns **true** if the rule exists in the collection of added rules; returns **false** otherwise. |
| boolean | Returns **true** if the rule exists in the collection of added rules; returns **false** otherwise.|
**Example**
......@@ -127,6 +128,6 @@ Checks whether the specified rule exists in the collection of added rules. If th
hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS);
// Check whether the added rule exists in the collection of added rules.
hichecker.contains(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // Return true.
hichecker.contains(hichecker.RULE_CAUTION_PRINT_LOG); // Return false.
```
\ No newline at end of file
hichecker.contains(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true;
hichecker.contains(hichecker.RULE_CAUTION_PRINT_LOG); // return false;
```
# HiLog
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
The HiLog subsystem allows your applications or services to output logs based on the specified type, level, and format string. Such logs help you learn the running status of applications and better debug programs.
This document describes only API functions. For details about log printing requirements, see [Logging Guide](../../../contribute/OpenHarmony-Log-guide.md).
> **NOTE**<br>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......@@ -9,184 +12,201 @@
import hilog from '@ohos.hilog';
```
## hilog.isLoggable
## hilog.debug
debug(domain: number, tag: string, format: string, ...args: any[]) : void
isLoggable(domain: number, tag: string, level: LogLevel) : boolean
Prints logs of the DEBUG level.
Checks whether logs are printable based on the specified service domain, log tag, and log level.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters**
| Name| Type | Mandatory | Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes | String constant used to identify the class or service behavior. |
| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default. |
| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string. |
| Name| Type | Mandatory| Description |
| ------ | --------------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| level | [LogLevel](#loglevel) | Yes | Log level. |
**Return value**
| Type | Description |
| ------- | ------------------------------------------------------------ |
| boolean | Returns **true** logs are printable based on the specified service domain, log tag, and log level; returns **false** otherwise.|
**Example**
```js
hilog.debug(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0);
hilog.isLoggable(0x0001, "testTag", hilog.LogLevel.INFO);
```
**Output**
## LogLevel
```
09-08 12:49:35.941 1547 2452 D FF00/testTag: 1: hello World 3.0
```
Enumerates the log levels.
## hilog.info
**System capability**: SystemCapability.HiviewDFX.HiLog
info(domain: number, tag: string, format: string, ...args: any[]) : void
| Name | Default Value| Description |
| ----- | ------ | ------------------------------------------------------------ |
| DEBUG | 3 | Log level used to record more detailed process information than INFO logs to help developers analyze service processes and locate faults.|
| INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running,<br>for example, no network signal or login failure.<br>These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.|
| WARN | 5 | Log level used to record severe, unexpected faults that have little impact on users and can be rectified by the programs themselves or through simple operations.|
| ERROR | 6 | Log level used to record program or functional errors that affect the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.|
| FATAL | 7 | Log level used to record program or functionality crashes that cannot be rectified. |
## hilog.debug
debug(domain: number, tag: string, format: string, ...args: any[]) : void
Prints logs of the INFO level.
Prints DEBUG logs.
DEBUG logs are not recorded in official versions by default. They are available in debug versions or in official versions with the debug function enabled.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters**
| Name| Type | Mandatory | Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes | String constant used to identify the class or service behavior. |
| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default. |
| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string. |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
This example is used to output a DEBUG log with the format string being `"%{public}s World %{private}d"`. The variable `%{public}s` is a plaintext string, and the variable `%{private}d` is a private integer.
```js
hilog.info(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0);
hilog.debug(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3);
```
**Output**
If `"hello"` is filled in `%{public}s` and `3` in `%{private}d`, the output log is as follows:
```
09-08 12:49:35.941 1547 2452 I FF00/testTag: 1: hello World 3.0
08-05 12:21:47.579 2695-2703/com.example.myapplication D 00001/testTag: hello World <private>
```
## hilog.warn
## hilog.info
warn(domain: number, tag: string, format: string, ...args: any[]) : void
info(domain: number, tag: string, format: string, ...args: any[]) : void
Prints logs of the WARN level.
Prints INFO logs.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters**
| Name| Type | Mandatory | Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes | String constant used to identify the class or service behavior. |
| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default. |
| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string. |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
This example is used to output an INFO log with the format string being `"%{public}s World %{private}d"`. The variable `%{public}s` is a plaintext string, and the variable `%{private}d` is a private integer.
```js
hilog.warn(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0);
hilog.info(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3);
```
**Output**
If `"hello"` is filled in `%{public}s` and `3` in `%{private}d`, the output log is as follows:
```
09-08 12:49:35.941 1547 2452 W FF00/testTag: 1: hello World 3.0
08-05 12:21:47.579 2695-2703/com.example.myapplication I 00001/testTag: hello World <private>
```
## hilog.error
## hilog.warn
error(domain: number, tag: string, format: string, ...args: any[]) : void
warn(domain: number, tag: string, format: string, ...args: any[]) : void
Prints logs of the ERROR level.
Prints WARN logs.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters**
| Name| Type | Mandatory | Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes | String constant used to identify the class or service behavior. |
| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default. |
| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string. |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
This example is used to output a WARN log with the format string being `"%{public}s World %{private}d"`. The variable `%{public}s` is a plaintext string, and the variable `%{private}d` is a private integer.
```js
hilog.error(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0);
hilog.warn(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3);
```
**Output**
If `"hello"` is filled in `%{public}s` and `3` in `%{private}d`, the output log is as follows:
```
09-08 12:49:35.941 1547 2452 E FF00/testTag: 1: hello World 3.0
08-05 12:21:47.579 2695-2703/com.example.myapplication W 00001/testTag: hello World <private>
```
## hilog.fatal
## hilog.error
fatal(domain: number, tag: string, format: string, ...args: any[]) : void
error(domain: number, tag: string, format: string, ...args: any[]) : void
Prints logs of the FATAL level.
Prints ERROR logs.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters**
| Name| Type | Mandatory | Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes | String constant used to identify the class or service behavior. |
| format | string | Yes | String constant format, including the parameter type and privacy identifier. A parameter without the privacy identifier is treated as a privacy parameter by default. |
| args | any[] | Yes | Variable-length parameter list corresponding to the parameter type in the format string. The number and type of parameters must map to the identifier in the format string. |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
This example is used to output an ERROR log with the format string being `"%{public}s World %{private}d"`. The variable `%{public}s` is a plaintext string, and the variable `%{private}d` is a private integer.
```js
hilog.fatal(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0);
hilog.error(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3);
```
**Output**
If `"hello"` is filled in `%{public}s` and `3` in `%{private}d`, the output log is as follows:
```
09-08 12:49:35.941 1547 2452 F FF00/testTag: 1: hello World 3.0
08-05 12:21:47.579 2695-2703/com.example.myapplication E 00001/testTag: hello World <private>
```
## hilog.isLoggable
## hilog.fatal
isLoggable(domain: number, tag: string, level: LogLevel) : boolean
fatal(domain: number, tag: string, format: string, ...args: any[]) : void
Checks whether printing is enabled for a domain, tag, or log level.
Prints FATAL logs.
**System capability**: SystemCapability.HiviewDFX.HiLog
**Parameters**
| Name| Type | Mandatory | Description |
| ------ | --------------------- | ---- | ------------------------------------------ |
| domain | number | Yes | Service domain. The value ranges from **0x0** to **0xFFFFF**. |
| tag | string | Yes | String constant used to identify the class or service behavior. |
| level | [LogLevel](#loglevel) | Yes | Log level. |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
This example is used to output a FATAL log with the format string being `"%{public}s World %{private}d"`. The variable `%{public}s` is a plaintext string, and the variable `%{private}d` is a private integer.
```js
hilog.isLoggable(0xFF00, "testTag", hilog.DEBUG);
hilog.fatal(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3);
```
## LogLevel
If `"hello"` is filled in `%{public}s` and `3` in `%{private}d`, the output log is as follows:
Enumerates event types.
**System capability**: SystemCapability.HiviewDFX.HiLog
| Name | Default Value | Description |
| ----- | ------ | ----------- |
| DEBUG | 3 | DEBUG level |
| INFO | 4 | INFO level |
| WARN | 5 | WARN level |
| ERROR | 6 | ERROR level |
| FATAL | 7 | FATAL level |
```
08-05 12:21:47.579 2695-2703/com.example.myapplication F 00001/testTag: hello World <private>
```
......@@ -4,7 +4,7 @@
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Openharmony Universal KeyStore (HUKS) provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations.
OpenHarmony Universal KeyStore (HUKS) provides KeyStore (KS) capabilities for applications, including key management and key cryptography operations.
HUKS also provides APIs for applications to import or generate keys.
## Modules to Import
......
# PermissionRequestResult
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the permission request result.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Attributes
......
# ProcessRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides process running information.
## Modules to Import
```js
import appManager from '@ohos.application.appManager'
```
## Usage
......
......@@ -62,7 +62,7 @@ Obtains the value of a data item.
- Example
```typescript
import featureAbility from '@ohos.featureAbility';
import featureAbility from '@ohos.ability.featureAbility';
// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
let brightness = 'settings.screen.brightness';
......@@ -97,7 +97,7 @@ If the specified data item exists in the database, the **setValueSync** method u
- Example
```typescript
import featureAbility from '@ohos.featureAbility';
import featureAbility from '@ohos.ability.featureAbility';
// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync
method will update the value of the data item.)
......
# Progress
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
......@@ -25,7 +25,7 @@ Progress(value: { value: number, total?: number, type?: ProgressType})
Creates a progress bar.
- Parameters
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
| value | number | Yes | - | Current progress. |
| total | number | No | 100 | Total progress. |
......@@ -33,7 +33,7 @@ Creates a progress bar.
- ProgressType enums
| Name | Description |
| Name | Description |
| -------- | -------- |
| Linear | Linear type. |
| Ring<sup>8+</sup> | Ring type without scale. The ring fills up as the progress increases. |
......
# QRCode
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
......@@ -23,14 +23,14 @@ None
QRCode(value: string)
- Parameters
| Name | Type | Mandatory | Default Value | Description |
| Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
| value | string | Yes | - | QR code content string. |
## Attributes
| Name | Type | Default Value | Description |
| Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- |
| color | Color | Black | QR code color. |
......
en/device-dev/driver/figures/HCB-using-process.png

13.4 KB | W: 0px | H: 0px

en/device-dev/driver/figures/HCB-using-process.png

11.2 KB | W: 0px | H: 0px

en/device-dev/driver/figures/HCB-using-process.png
en/device-dev/driver/figures/HCB-using-process.png
en/device-dev/driver/figures/HCB-using-process.png
en/device-dev/driver/figures/HCB-using-process.png
  • 2-up
  • Swipe
  • Onion skin
en/device-dev/driver/figures/hdf-driver-model.png

20.6 KB | W: 0px | H: 0px

en/device-dev/driver/figures/hdf-driver-model.png

14.8 KB | W: 0px | H: 0px

en/device-dev/driver/figures/hdf-driver-model.png
en/device-dev/driver/figures/hdf-driver-model.png
en/device-dev/driver/figures/hdf-driver-model.png
en/device-dev/driver/figures/hdf-driver-model.png
  • 2-up
  • Swipe
  • Onion skin
此差异已折叠。
en/device-dev/quick-start/figures/en-us_image_0000001226634716.png

38.3 KB | W: 0px | H: 0px

en/device-dev/quick-start/figures/en-us_image_0000001226634716.png

49.5 KB | W: 0px | H: 0px

en/device-dev/quick-start/figures/en-us_image_0000001226634716.png
en/device-dev/quick-start/figures/en-us_image_0000001226634716.png
en/device-dev/quick-start/figures/en-us_image_0000001226634716.png
en/device-dev/quick-start/figures/en-us_image_0000001226634716.png
  • 2-up
  • Swipe
  • Onion skin
en/device-dev/quick-start/figures/en-us_image_0000001226922302.png

37.2 KB | W: 0px | H: 0px

en/device-dev/quick-start/figures/en-us_image_0000001226922302.png

42.5 KB | W: 0px | H: 0px

en/device-dev/quick-start/figures/en-us_image_0000001226922302.png
en/device-dev/quick-start/figures/en-us_image_0000001226922302.png
en/device-dev/quick-start/figures/en-us_image_0000001226922302.png
en/device-dev/quick-start/figures/en-us_image_0000001226922302.png
  • 2-up
  • Swipe
  • Onion skin
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部