diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 63a868c4d55ac2ac6a76b00ea9904596da347d92..871c522053d2c728a21f4059ef73a0e75d6ed4e2 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -120,6 +120,7 @@ - [@ohos.events.emitter (Emitter)](js-apis-emitter.md) - [@ohos.notificationManager (NotificationManager) (Recommended)](js-apis-notificationManager.md) - [@ohos.notificationSubscribe (NotificationSubscribe) (Recommended)](js-apis-notificationSubscribe.md) + - [@ohos.application.StaticSubscriberExtensionContext (NotificationSubscribe) (Recommended)](js-apis-application-StaticSubscriberExtensionContext.md) - [System Common Events (To Be Deprecated Soon)](commonEvent-definitions.md) - [@ohos.commonEvent (Common Event) (To Be Deprecated Soon)](js-apis-commonEvent.md) - [@ohos.notification (Notification) (To Be Deprecated Soon)](js-apis-notification.md) @@ -137,6 +138,10 @@ - [NotificationFlags](js-apis-inner-notification-notificationFlags.md) - [NotificationRequest](js-apis-inner-notification-notificationRequest.md) - [NotificationSlot](js-apis-inner-notification-notificationSlot.md) + - [NotificationSorting](js-apis-inner-notification-notificationSorting.md) + - [NotificationSortingMap](js-apis-inner-notification-notificationSortingMap.md) + - [NotificationSubscribeInfo](js-apis-inner-notification-notificationSubscribeInfo.md) + - [NotificationSubscriber](js-apis-inner-notification-notificationSubscriber.md) - [NotificationTemplate](js-apis-inner-notification-notificationTemplate.md) - [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) - Common Events @@ -330,6 +335,7 @@ - [@ohos.batteryStatistics (Battery Statistics)](js-apis-batteryStatistics.md) - [@ohos.brightness (Screen Brightness)](js-apis-brightness.md) - [@ohos.charger (Charging Type)](js-apis-charger.md) + - [@ohos.cooperate (Screen Hopping)](js-apis-devicestatus-cooperate.md) - [@ohos.deviceInfo (Device Information)](js-apis-device-info.md) - [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md) - [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md) diff --git a/en/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md b/en/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md new file mode 100644 index 0000000000000000000000000000000000000000..f1c7c82e6af9bdeacc971596d47b217c72f1ddc9 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md @@ -0,0 +1,161 @@ +# @ohos.application.StaticSubscriberExtensionContext (StaticSubscriberExtensionContext) + +The **StaticSubscriberExtensionContext** module, inherited from **ExtensionContext**, provides context for StaticSubscriberExtensionAbilities. + +You can use the APIs of this module to start StaticSubscriberExtensionAbilities. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The APIs of this module can be used only in the stage model. + +## Usage + +Before using the **StaticSubscriberExtensionContext** module, you must first obtain a **StaticSubscriberExtensionAbility** instance. + +```ts +import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility' + +export default class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility { + context = this.context; +}; +``` + +## StaticSubscriberExtensionContext.startAbility + +startAbility(want: Want, callback: AsyncCallback<void>): void; + +Starts an ability that belongs to the same application as this StaticSubscriberExtensionAbility. This API uses an asynchronous callback to return the result. + +Observe the following when using this API: + - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission. + - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------- | ---- | -------------------------- | +| want | [Want](js-apis-application-want.md) | Yes | Want information about the target ability. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Error codes** + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | +| 16300003 | The target application is not self application. | + +**Example** + + ```ts + let want = { + bundleName: "com.example.myapp", + abilityName: "MyAbility" + }; + + try { + this.context.startAbility(want, (error) => { + if (error) { + // Process service logic errors. + console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) + + ' error.message: ' + JSON.stringify(error.message)); + return; + } + // Carry out normal service processing. + console.log('startAbility succeed'); + }); + } catch (paramError) { + // Process input parameter errors. + console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) + + ' error.message: ' + JSON.stringify(paramError.message)); + } + ``` + +## StaticSubscriberExtensionContext.startAbility + +startAbility(want: Want): Promise<void>; + +Starts an ability that belongs to the same application as this StaticSubscriberExtensionAbility. This API uses a promise to return the result. + +Observe the following when using this API: + - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission. + - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**System API**: This is a system API and cannot be called by third-party applications. + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ----------------------------------- | ---- | ----------------------- | +| want | [Want](js-apis-application-want.md) | Yes | Want information about the target ability.| + +**Return value** + +| Type | Description | +| ------------------- | ------------------------- | +| Promise<void> | Promise used to return the result.| + +**Error codes** + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + +| ID| Error Message | +| -------- | ------------------------------------------------------------ | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | +| 16300003 | The target application is not self application. | + +**Example** + + ```ts + let want = { + bundleName: "com.example.myapp", + abilityName: "MyAbility" + }; + + try { + this.context.startAbility(want) + .then(() => { + // Carry out normal service processing. + console.log('startAbility succeed'); + }) + .catch((error) => { + // Process service logic errors. + console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) + + ' error.message: ' + JSON.stringify(error.message)); + }); + } catch (paramError) { + // Process input parameter errors. + console.log('startAbility failed, error.code: ' + JSON.stringify(paramError.code) + + ' error.message: ' + JSON.stringify(paramError.message)); + } + ``` diff --git a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md index 096433a60c44904bbe9b2f25d09e9384e192c7fb..c28c4372ba1cf10ad9c67669913de1b4ac06ae17 100644 --- a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md @@ -13,6 +13,14 @@ The **StaticSubscriberExtensionAbility** module provides Extension abilities for import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'; ``` +## Attributes + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +| Name | Type | Readable| Writable| Description | +| ------- | ------------------------------------------------------------ | ---- | ---- | -------- | +| context | [StaticSubscriberExtensionContext](js-apis-application-StaticSubscriberExtensionContext.md) | Yes | No | Context.| + ## StaticSubscriberExtensionAbility.onReceiveEvent onReceiveEvent(event: CommonEventData): void; @@ -30,7 +38,6 @@ Callback of the common event of a static subscriber. | event | [CommonEventData](js-apis-commonEventManager.md#commoneventdata) | Yes| Common event of a static subscriber.| **Example** - ```ts class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility { onReceiveEvent(event) { diff --git a/en/application-dev/reference/errorcodes/errorcode-ability.md b/en/application-dev/reference/errorcodes/errorcode-ability.md index b8ca0fb14876dadf9b5e925f715430c1f6a26e24..fa1aea9015cd83a9ba19c7c5c0c4f75610d15c73 100644 --- a/en/application-dev/reference/errorcodes/errorcode-ability.md +++ b/en/application-dev/reference/errorcodes/errorcode-ability.md @@ -204,7 +204,7 @@ The system has a large number of concurrent requests. No action is required. Wait for the previous abilities to finish startup. -## 100001 Internal Error +## 16000050 Internal Error **Error Message** @@ -519,7 +519,7 @@ The method has registered. **Description** -THis error code is reported when the method has been registered. +This error code is reported when the method has been registered. **Possible Causes** @@ -583,6 +583,24 @@ The mission listener does not exist. Check the mission listener ID. +## 16300003 Target Application Is Not the Invoker Application + +**Error Message** + +The target application is not self application. + +**Description** + +This error code is reported when the application to start is not the application that calls the API. + +**Possible Causes** + +The application to start and the invoker application are not the same application. + +**Solution** + +Ensure that the application to start is the invoker application. + ## 18500001 Invalid Bundle Name **Error Message** @@ -638,7 +656,7 @@ This error code is reported when the patch package fails to be deployed. 4. If a patch package has been deployed, the **versionCode** of the new patch package is not later than that of the previous patch package. 5. If the **type** field is set to **patch**, the signature information is different from that of the application. 6. If the **type** field is set to **patch** and a debug version is to be installed, a **hotreload** patch is in use. -7. If the **type** field is set to **hotreload** and a debug version is to be installed, a **patch** patch is in use. If the **type** field is set to **hotreload**, a release version is to be installed. +7. If the **type** field is set to **hotreload** and a debug version is to be installed, a **patch** package is in use. If the **type** field is set to **hotreload**, a release version is to be installed. **Solution** @@ -656,7 +674,7 @@ This error code is reported when the patch package fails to be enabled. **Possible Causes** -The patch package is in an incorect state. +The patch package is in an incorrect state. **Solution** @@ -706,7 +724,7 @@ Failed to unload the patch. **Description** -This error code is reported when when the Ark engine fails to uninstall the patch. +This error code is reported when the Ark engine fails to uninstall the patch. **Possible Causes** @@ -733,3 +751,21 @@ Common kernel errors such as memory application and multi-thread processing erro **Solution** Ensure sufficient sytem memory. + +## 18500009 Application Has a Quick Fix Task Being Processed + +**Error Message** + +The application has a apply quick fix task that is being processed. + +**Description** + +This error code is reported when the application has a quick fix task that is under processing. + +**Possible Causes** + +When you try to cancel a quick fix task for an application, the application has a quick repair task that is under processing. + +**Solution** + +Wait until the quick fix task is complete.