提交 37f16273 编写于 作者: E ester.zhou

Update docs (16118)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 36eb3ab3
# Adding a WantAgent Object to a Notification # Adding a WantAgent Object to a Notification
A [WantAgent](../reference/apis/js-apis-app-ability-wantAgent.md) object encapsulates an intention to start a specified ability, release a common event, and more. In OpenHarmony, a **WantAgent** object can be passed in a notification from the publisher to the subscriber, so as to trigger the intention specified. For example, you may want the user to start a specific ability by touching the notification published by your application. In this case, you can add a **WantAgent** object that encapsulates such an action to the notification. After receiving the **WantAgent** object, the system triggers it once the user touches the notification from the notification panel, starting the specified ability. A **WantAgent** object encapsulates an intention to start a specified ability, release a common event, and more. In OpenHarmony, a **WantAgent** object can be passed in a notification from the publisher to the subscriber, so as to trigger the intention specified. For example, you may want the user to start a specific ability by touching the notification published by your application. In this case, you can add a **WantAgent** object that encapsulates such an action to the notification. After receiving the **WantAgent** object, the system triggers it once the user touches the notification from the notification panel, starting the specified ability.
Below you can see the process of adding a **WantAgent** object to a notification. The notification publisher requests a **WantAgent** object from the Ability Manager Service (AMS), and then sends a notification carrying the **WantAgent** object to the home screen. When the user touches the notification from the notification panel on the home screen, the **WantAgent** object is triggered. Below you can see the process of adding a **WantAgent** object to a notification. The notification publisher requests a **WantAgent** object from the Ability Manager Service (AMS), and then sends a notification carrying the **WantAgent** object to the home screen. When the user touches the notification from the notification panel on the home screen, the **WantAgent** object is triggered.
**Figure 1** Publishing a notification with a WantAgent object **Figure 1** Publishing a notification with a WantAgent object
![notification-with-wantagent](figures/notification-with-wantagent.png) ![notification-with-wantagent](figures/notification-with-wantagent.png)
## Available APIs ## Available APIs
For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/js-apis-app-ability-wantAgent.md). For details about the APIs, see [WantAgent](../reference/apis/js-apis-wantAgent.md).
| Name| Description| | Name| Description|
| -------- | -------- | | -------- | -------- |
...@@ -23,20 +24,18 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ...@@ -23,20 +24,18 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
## How to Develop ## How to Develop
1. [Enable notification](notification-enable.md). An application can use the notification feature only after being authorized by the user. 1. Import the modules.
2. Import the modules.
```typescript ```ts
import notificationManager from '@ohos.notificationManager'; import NotificationManager from '@ohos.notificationManager';
import wantAgent from '@ohos.app.ability.wantAgent'; import wantAgent from '@ohos.app.ability.wantAgent';
``` ```
3. Create a **WantAgentInfo** object. 2. Create a **WantAgentInfo** object.
Scenario 1: Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object for starting a UIAbility component. Scenario 1: Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object for starting a UIAbility component.
```typescript ```ts
let wantAgentObj = null; // Save the WantAgent object created. It will be used to complete the trigger operations. let wantAgentObj = null; // Save the WantAgent object created. It will be used to complete the trigger operations.
// Set the action type through operationType of WantAgentInfo. // Set the action type through operationType of WantAgentInfo.
...@@ -44,8 +43,8 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ...@@ -44,8 +43,8 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
wants: [ wants: [
{ {
deviceId: '', deviceId: '',
bundleName: 'com.example.myapplication', bundleName: 'com.example.test',
abilityName: 'EntryAbility', abilityName: 'com.example.test.MainAbility',
action: '', action: '',
entities: [], entities: [],
uri: '', uri: '',
...@@ -55,12 +54,12 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ...@@ -55,12 +54,12 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0, requestCode: 0,
wantAgentFlags:[wantAgent.WantAgentFlags.CONSTANT_FLAG] wantAgentFlags:[wantAgent.WantAgentFlags.CONSTANT_FLAG]
}; }
``` ```
Scenario 2: Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object for publishing a [common event](../application-models/common-event-overview.md). Scenario 2: Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object for publishing a [common event](../application-models/common-event-overview.md).
```typescript ```ts
let wantAgentObj = null; // Save the WantAgent object created. It will be used to complete the trigger operations. let wantAgentObj = null; // Save the WantAgent object created. It will be used to complete the trigger operations.
// Set the action type through operationType of WantAgentInfo. // Set the action type through operationType of WantAgentInfo.
...@@ -77,27 +76,27 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ...@@ -77,27 +76,27 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
} }
``` ```
4. Invoke the [getWantAgent()](../reference/apis/js-apis-app-ability-wantAgent.md#wantagentgetwantagent) API to create a **WantAgent** object. 3. Create a **WantAgent** object.
```typescript ```ts
// Create a WantAgent object. // Create a WantAgent object.
wantAgent.getWantAgent(wantAgentInfo, (err, data) => { wantAgent.getWantAgent(wantAgentInfo, (err, data) => {
if (err) { if (err) {
console.error('[WantAgent]getWantAgent err=' + JSON.stringify(err)); console.error('[WantAgent]getWantAgent err=' + JSON.stringify(err));
return; } else {
console.info('[WantAgent]getWantAgent success');
wantAgentObj = data;
} }
console.info('[WantAgent]getWantAgent success');
wantAgentObj = data;
}); });
``` ```
5. Create a **NotificationRequest** object and publish a notification that carries the **WantAgent** object. 4. Create a **NotificationRequest** object.
```typescript ```ts
// Create a NotificationRequest object. // Create a NotificationRequest object.
let notificationRequest = { let notificationRequest = {
content: { content: {
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: NotificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: 'Test_Title', title: 'Test_Title',
text: 'Test_Text', text: 'Test_Text',
...@@ -108,14 +107,29 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ...@@ -108,14 +107,29 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
label: 'TEST', label: 'TEST',
wantAgent: wantAgentObj, wantAgent: wantAgentObj,
} }
```
5. Publish a notification that carries the **WantAgent** object.
notificationManager.publish(notificationRequest, (err) => { ```ts
// Publish a notification.
NotificationManager.publish(notificationRequest, (err) => {
if (err) { if (err) {
console.error(`[ANS] failed to publish, error[${err}]`); console.error(`[ANS] failed to publish, error[${err}]`);
return; return;
} }
console.info(`[ANS] publish success`); console.info(`[ANS] publish success `);
}); });
``` ```
6. When the user touches the notification from the notification panel, the system automatically triggers the action specified in the **WantAgent** object. 6. When the user touches the notification from the notification panel, the system automatically triggers the action specified in the **WantAgent** object.
```ts
// Trigger the WantAgent object.
let triggerInfo = {
code: 0
}
wantAgent.trigger(wantAgentObj, triggerInfo, (completeData) => {
console.info('[WantAgent]getWantAgent success, completeData: ', + JSON.stringify(completeData));
});
```
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
The progress notification is a commonly used notification type, mainly used to display the progress of an ongoing operation, such as file downloading. When publishing a progress notification through the notification subsystem, you can use the readily available template by specifying the related attributes, such as the template name and template data. The progress notification is a commonly used notification type, mainly used to display the progress of an ongoing operation, such as file downloading. When publishing a progress notification through the notification subsystem, you can use the readily available template by specifying the related attributes, such as the template name and template data.
In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#notificationtemplate), which can only be of the progress type, **data** indicates custom template data. In the [NotificationTemplate](../reference/apis/js-apis-inner-notification-notificationTemplate.md), which can only be of the progress type, **data** indicates custom template data.
## Available APIs ## Available APIs
...@@ -20,13 +20,13 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n ...@@ -20,13 +20,13 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n
2. Import the module. 2. Import the module.
```ts ```ts
import notificationManager from '@ohos.notificationManager'; import NotificationManager from '@ohos.notificationManager';
``` ```
3. Check whether a specific template is supported. In this example, the template of the **downloadTemplate** type is checked. 3. Check whether a specific template is supported. In this example, the template of the **downloadTemplate** type is checked.
```ts ```ts
notificationManager.isSupportTemplate('downloadTemplate').then((data) => { NotificationManager.isSupportTemplate('downloadTemplate').then((data) => {
console.info(`[ANS] isSupportTemplate success`); console.info(`[ANS] isSupportTemplate success`);
let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means the opposite. let isSupportTpl: boolean = data; // The value true means that the template of the downloadTemplate type is supported, and false means the opposite.
// ... // ...
...@@ -44,7 +44,7 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n ...@@ -44,7 +44,7 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n
let notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: NotificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: 'test_title', title: 'test_title',
text: 'test_text', text: 'test_text',
...@@ -59,7 +59,7 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n ...@@ -59,7 +59,7 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n
} }
// Publish the notification. // Publish the notification.
notificationManager.publish(notificationRequest, (err) => { NotificationManager.publish(notificationRequest, (err) => {
if (err) { if (err) {
console.error(`[ANS] failed to publish, error[${err}]`); console.error(`[ANS] failed to publish, error[${err}]`);
return; return;
......
# @ohos.systemParameter # @ohos.systemParameter (System Parameter)
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters. The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see For details about the system parameter design principles and definitions, see
[Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md). [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
> **NOTE** > **NOTE**
> - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterV9](js-apis-system-parameterV9.md) instead. > - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterEnhance](js-apis-system-parameterEnhance.md) instead.
> - 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 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 provided by this module are system APIs. > - The APIs provided by this module are system APIs.
> - Third-party applications cannot use the APIs provided by this module, because system parameters each require specific discretionary access control (DAC) and MAC permissions. > - Third-party applications cannot use the APIs provided by this module, because system parameters each require specific discretionary access control (DAC) and MAC permissions.
......
...@@ -3,125 +3,161 @@ ...@@ -3,125 +3,161 @@
## 1500001 Want Action Is Null ## 1500001 Want Action Is Null
**Error Message** **Error Message**
Want action is null
The action field in the want parameter is null.
**Description** **Description**
This error code is reported when the **Action** attribute in the **want** is null for the event to send.
This error code is reported when the **Action** attribute in the **want** object is null for the event to send.
**Possible Causes** **Possible Causes**
The **Action** attribute in the **want** is null for the event to send.
The **Action** attribute in the **want** object is null for the event to send.
**Solution** **Solution**
Make sure the **Action** attribute in the **want** is not null.
Make sure the **Action** attribute in the **want** object is not null.
## 1500002 Failed to Send Common Events from a Sandbox Application ## 1500002 Failed to Send Common Events from a Sandbox Application
**Error Message** **Error Message**
sandbox application can not send common event
A sandbox application cannot send common events.
**Description** **Description**
This error code is reported when an attempt is made to send a common event from a sandbox application. This error code is reported when an attempt is made to send a common event from a sandbox application.
**Possible Causes** **Possible Causes**
Common events from a sandbox application are blocked. Common events from a sandbox application are blocked.
**Solution** **Solution**
Check whether the application used to send a common event is a sandbox application. If so, switch to another application. Check whether the application used to send a common event is a sandbox application. If so, switch to another application.
## 1500003 Event Sending Frequency Is Too High ## 1500003 Event Sending Frequency Is Too High
**Error Message** **Error Message**
common event send frequency too high
Too many common events are send in a short period of time.
**Description** **Description**
This error code is reported when the application sends common events too frequently. This error code is reported when the application sends common events too frequently.
**Possible Causes** **Possible Causes**
The number of common events sent by the application in a given time frame has reached the maximum. The number of common events sent by the application in a given time frame has reached the maximum.
**Solution** **Solution**
Do not send common events too frequently. Do not send common events too frequently.
## 1500004 Failed to Send System Common Events ## 1500004 Failed to Send System Common Events
**Error Message** **Error Message**
not System services or System app
A third-party application cannot send system common events.
**Description** **Description**
This error code is reported when the application cannot send system common events. This error code is reported when the application cannot send system common events.
**Possible Causes** **Possible Causes**
The application is not a system application or system service. The application is not a system application or system service.
**Solution** **Solution**
Make sure the application to send system common events is a system application or system service. Make sure the application to send system common events is a system application or system service.
## 1500005 Subscriber Not Found ## 1500005 Subscriber Not Found
**Error Message** **Error Message**
subscriber can not found
The subscriber is not found.
**Description** **Description**
This error code is reported when the subscriber cannot be found. This error code is reported when the subscriber cannot be found.
**Possible Causes** **Possible Causes**
The subscriber is deleted. The subscriber is deleted.
**Solution** **Solution**
Check whether the subscription has already been canceled. If the subscription has been canceled, the subscriber is deleted. Check whether the subscription has already been canceled. If the subscription has been canceled, the subscriber is deleted.
## 1500006 Invalid User ID ## 1500006 Invalid User ID
**Error Message** **Error Message**
usreId is invalid
Invalid userId.
**Description** **Description**
This error code is reported when the user ID is invalid. This error code is reported when the user ID is invalid.
**Possible Causes** **Possible Causes**
The user ID is different from the system user ID, or the application is not a system application or subsystem process.
The user ID is different from the system user ID, or the application is not a system application or system service.
**Solution** **Solution**
Check whether the current user ID is the same as the system user ID. If they are different, check whether the application is a system application or subsystem process 1. Make sure the current user ID is the same as the system user ID.
2. Make sure the application is a system application or system service.
## 1500007 Failed to Send a Request Through IPC ## 1500007 Failed to Send a Request Through IPC
**Error Message** **Error Message**
message send error
Failed to send the message.
**Description** **Description**
This error code is reported when the attempt to send a request through IPC fails. This error code is reported when the attempt to send a request through IPC fails.
**Possible Causes** **Possible Causes**
The connection object fails to be created. The connection object fails to be created.
**Solution** **Solution**
Do not set up connections frequently. Try again later. Do not set up connections frequently. Try again later.
## 1500008 Failed to Read Data ## 1500008 Failed to Read Data
**Error Message** **Error Message**
CEMS error
Failed to read the data.
**Description** **Description**
This error code is reported when an error occurs on the server. This error code is reported when an error occurs on the server.
**Possible Causes** **Possible Causes**
A service exception occurs when the server processes data. A service exception occurs when the server processes data.
**Solution** **Solution**
Try again later. Try again later.
## 1500009 System Error ## 1500009 System Error
**Error Message** **Error Message**
system error
System error.
**Description** **Description**
This error code is reported when an exception occurs in the system during service processing, for example, when the current system time fails to be obtained. This error code is reported when an exception occurs in the system during service processing, for example, when the current system time fails to be obtained.
**Possible Causes** **Possible Causes**
A system fault occurs. A system fault occurs.
**Solution** **Solution**
Try again later.
Try again later.
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册