diff --git a/en/application-dev/notification/figures/notification-with-wantagent.png b/en/application-dev/notification/figures/notification-with-wantagent.png new file mode 100644 index 0000000000000000000000000000000000000000..234ef895c918404598cf7640f9d072de2bb2d0d0 Binary files /dev/null and b/en/application-dev/notification/figures/notification-with-wantagent.png differ diff --git a/en/application-dev/notification/notification-with-wantagent.md b/en/application-dev/notification/notification-with-wantagent.md index d8f0321d28738749d6ed6073e49f26181c22e706..6542a37682198bcf15894fefe3ae612f8402668e 100644 --- a/en/application-dev/notification/notification-with-wantagent.md +++ b/en/application-dev/notification/notification-with-wantagent.md @@ -1,16 +1,17 @@ # 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. **Figure 1** Publishing a notification with a WantAgent object + ![notification-with-wantagent](figures/notification-with-wantagent.png) ## 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| | -------- | -------- | @@ -23,20 +24,18 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ ## How to Develop -1. [Enable notification](notification-enable.md). An application can use the notification feature only after being authorized by the user. - -2. Import the modules. +1. Import the modules. - ```typescript - import notificationManager from '@ohos.notificationManager'; + ```ts + import NotificationManager from '@ohos.notificationManager'; 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. - ```typescript + ```ts 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. @@ -44,8 +43,8 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ wants: [ { deviceId: '', - bundleName: 'com.example.myapplication', - abilityName: 'EntryAbility', + bundleName: 'com.example.test', + abilityName: 'com.example.test.MainAbility', action: '', entities: [], uri: '', @@ -55,12 +54,12 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ operationType: wantAgent.OperationType.START_ABILITY, requestCode: 0, 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). - ```typescript + ```ts 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. @@ -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. wantAgent.getWantAgent(wantAgentInfo, (err, data) => { if (err) { - console.error('[WantAgent]getWantAgent err=' + JSON.stringify(err)); - return; + console.error('[WantAgent]getWantAgent err=' + JSON.stringify(err)); + } 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. let notificationRequest = { content: { - contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + contentType: NotificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: 'Test_Title', text: 'Test_Text', @@ -108,14 +107,29 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/ label: 'TEST', 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) { console.error(`[ANS] failed to publish, error[${err}]`); 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. + + ```ts + // Trigger the WantAgent object. + let triggerInfo = { + code: 0 + } + wantAgent.trigger(wantAgentObj, triggerInfo, (completeData) => { + console.info('[WantAgent]getWantAgent success, completeData: ', + JSON.stringify(completeData)); + }); + ``` diff --git a/en/application-dev/notification/progress-bar-notification.md b/en/application-dev/notification/progress-bar-notification.md index 76e3292d79ae3a91a032ccf516c649ab39eda9e3..4cb57a145d8a4abb6c24a3cd387f635452fd1be1 100644 --- a/en/application-dev/notification/progress-bar-notification.md +++ b/en/application-dev/notification/progress-bar-notification.md @@ -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. -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 @@ -20,13 +20,13 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n 2. Import the module. ```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. ```ts - notificationManager.isSupportTemplate('downloadTemplate').then((data) => { + NotificationManager.isSupportTemplate('downloadTemplate').then((data) => { 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. // ... @@ -44,7 +44,7 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n let notificationRequest = { id: 1, content: { - contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + contentType: NotificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: 'test_title', text: 'test_text', @@ -59,7 +59,7 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n } // Publish the notification. - notificationManager.publish(notificationRequest, (err) => { + NotificationManager.publish(notificationRequest, (err) => { if (err) { console.error(`[ANS] failed to publish, error[${err}]`); return; diff --git a/en/application-dev/reference/apis/js-apis-system-parameter.md b/en/application-dev/reference/apis/js-apis-system-parameter.md index ab3ae31887d1a2c55eb94c0164573834321e96c0..0dc490855181cedbe2199810dd45a28384c75c71 100644 --- a/en/application-dev/reference/apis/js-apis-system-parameter.md +++ b/en/application-dev/reference/apis/js-apis-system-parameter.md @@ -1,11 +1,11 @@ -# @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. For details about the system parameter design principles and definitions, see [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md). > **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 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. diff --git a/en/application-dev/reference/errorcodes/errorcode-CommonEventService.md b/en/application-dev/reference/errorcodes/errorcode-CommonEventService.md index be39f168e05c7b753f20ce07481d35b32f8df032..9b61d8e62ed722b1a3409d8d8ddcfe8c31962cc6 100644 --- a/en/application-dev/reference/errorcodes/errorcode-CommonEventService.md +++ b/en/application-dev/reference/errorcodes/errorcode-CommonEventService.md @@ -3,125 +3,161 @@ ## 1500001 Want Action Is Null **Error Message** -Want action is null + +The action field in the want parameter is null. **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** -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** -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 **Error Message** -sandbox application can not send common event + +A sandbox application cannot send common events. **Description** + This error code is reported when an attempt is made to send a common event from a sandbox application. **Possible Causes** + Common events from a sandbox application are blocked. **Solution** + 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 **Error Message** -common event send frequency too high + +Too many common events are send in a short period of time. **Description** + This error code is reported when the application sends common events too frequently. **Possible Causes** + The number of common events sent by the application in a given time frame has reached the maximum. **Solution** + Do not send common events too frequently. ## 1500004 Failed to Send System Common Events **Error Message** -not System services or System app + +A third-party application cannot send system common events. **Description** + This error code is reported when the application cannot send system common events. **Possible Causes** + The application is not a system application or system service. **Solution** + Make sure the application to send system common events is a system application or system service. ## 1500005 Subscriber Not Found **Error Message** -subscriber can not found + +The subscriber is not found. **Description** + This error code is reported when the subscriber cannot be found. **Possible Causes** + The subscriber is deleted. **Solution** + Check whether the subscription has already been canceled. If the subscription has been canceled, the subscriber is deleted. ## 1500006 Invalid User ID **Error Message** -usreId is invalid + +Invalid userId. **Description** + This error code is reported when the user ID is invalid. **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** -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 **Error Message** -message send error + +Failed to send the message. **Description** + This error code is reported when the attempt to send a request through IPC fails. **Possible Causes** + The connection object fails to be created. **Solution** + Do not set up connections frequently. Try again later. ## 1500008 Failed to Read Data **Error Message** -CEMS error + +Failed to read the data. **Description** + This error code is reported when an error occurs on the server. **Possible Causes** + A service exception occurs when the server processes data. **Solution** + Try again later. ## 1500009 System Error **Error Message** -system error + +System error. **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. **Possible Causes** + A system fault occurs. **Solution** -Try again later. + +Try again later. \ No newline at end of file