diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md index ff1bbfa2187c2a5ad868e28e11e08ae1a77ed705..0217f6d04cb40c4048170fc7e69a2a63c0231bc2 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md @@ -39,6 +39,7 @@ Enumerates the initial ability launch reasons. You can use it together with [onC | CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartabilitybycall).| | CONTINUATION | 3 | The ability is started by means of cross-device migration.| | APP_RECOVERY | 4 | The ability is automatically started when the application is restored from a fault.| +| SHARE10+ | 5 | The ability is started by calling [acquireShareData](js-apis-app-ability-abilityManager.md#acquiresharedata).| **Example** diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md index 3cb32c4a2cdcbf7dbe451e3a8e880bc3414cc689..19baae56611c1d0eec717eabbdad4cbd5bf0755b 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md @@ -45,7 +45,7 @@ Updates the configuration. This API uses an asynchronous callback to return the | Name | Type | Mandatory | Description | | --------- | ---------------------------------------- | ---- | -------------- | | config | [Configuration](js-apis-app-ability-configuration.md) | Yes | New configuration. You only need to configure the items to be updated.| -| callback | AsyncCallback\ | Yes | Callback used to return the API call result. You can perform error handling or custom processing in this callback. | +| callback | AsyncCallback\ | Yes | Callback used to return the API call result. You can perform error handling or custom processing in it. | **Error codes** @@ -72,7 +72,7 @@ const config = { try { abilityManager.updateConfiguration(config, (err) => { - if (err && err.code !== 0) { + if (err) { console.error('updateConfiguration fail, err: ${JSON.stringify(err)}'); } else { console.log('updateConfiguration success.'); @@ -103,7 +103,7 @@ Updates the configuration. This API uses a promise to return the result. | Type | Description | | ---------------------------------------- | ------- | -| Promise\ | Promise used to return the API call result. You can perform error handling or custom processing in this callback.| +| Promise\ | Promise used to return the API call result. You can perform error handling or custom processing in it.| **Error codes** @@ -153,7 +153,7 @@ Obtains the ability running information. This API uses an asynchronous callback | Name | Type | Mandatory | Description | | --------- | ---------------------------------------- | ---- | -------------- | -| callback | AsyncCallback\> | Yes | Callback used to return the API call result and the ability running information. You can perform error handling or custom processing in this callback. | +| callback | AsyncCallback\> | Yes | Callback used to return the API call result and the ability running information. You can perform error handling or custom processing in it. | **Error codes** @@ -170,7 +170,7 @@ import abilityManager from '@ohos.app.ability.abilityManager'; try { abilityManager.getAbilityRunningInfos((err, data) => { - if (err && err.code !== 0) { + if (err) { console.error('getAbilityRunningInfos fail, error: ${JSON.stringify(err)}'); } else { console.log('getAbilityRunningInfos success, data: ${JSON.stringify(data)}'); @@ -195,7 +195,7 @@ Obtains the UIAbility running information. This API uses a promise to return the | Type | Description | | ---------------------------------------- | ------- | -| Promise\> | Promise used to return the API call result and the UIAbility running information. You can perform error handling or custom processing in this callback.| +| Promise\> | Promise used to return the API call result and the UIAbility running information. You can perform error handling or custom processing in it.| **Error codes** @@ -236,7 +236,7 @@ Obtains the ExtensionAbility running information. This API uses an asynchronous | Name | Type | Mandatory | Description | | --------- | ---------------------------------------- | ---- | -------------- | | upperLimit | number | Yes| Maximum number of messages that can be obtained. The maximum value is 231-1.| -| callback | AsyncCallback\> | Yes | Callback used to return the API call result and the ExtensionAbility running information. You can perform error handling or custom processing in this callback. | +| callback | AsyncCallback\> | Yes | Callback used to return the API call result and the ExtensionAbility running information. You can perform error handling or custom processing in it. | **Error codes** @@ -254,8 +254,8 @@ import abilityManager from '@ohos.app.ability.abilityManager'; let upperLimit = 10; try { - abilityManager.getExtensionRunningInfos(upperLimit, (err, data) => { - if (err && err.code !== 0) { + abilityManager.getExtensionRunningInfos(upperLimit, (err, data) => { + if (err) { console.error('getExtensionRunningInfos fail, err: ${JSON.stringify(err)}'); } else { console.log('getExtensionRunningInfos success, data: ${JSON.stringify(data)}'); @@ -286,7 +286,7 @@ Obtains the ExtensionAbility running information. This API uses a promise to ret | Type | Description | | ---------------------------------------- | ------- | -| Promise\> | Promise used to return the API call result and the ExtensionAbility running information. You can perform error handling or custom processing in this callback.| +| Promise\> | Promise used to return the API call result and the ExtensionAbility running information. You can perform error handling or custom processing in it.| **Error codes** @@ -326,7 +326,7 @@ Obtains the top ability, which is the ability that has the window focus. This AP | Name | Type | Mandatory | Description | | --------- | ---------------------------------------- | ---- | -------------- | -| callback | AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | Callback used to return the API call result and the element name of the top ability. You can perform error handling or custom processing in this callback. | +| callback | AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | Callback used to return the API call result and the element name of the top ability. You can perform error handling or custom processing in it. | **Error codes** @@ -342,7 +342,7 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error import abilityManager from '@ohos.app.ability.abilityManager'; abilityManager.getTopAbility((err, data) => { - if (err && err.code !== 0) { + if (err) { console.error('getTopAbility fail, err: ${JSON.stringify(err)}'); } else { console.log('getTopAbility success, data: ${JSON.stringify(data)}'); @@ -362,7 +362,7 @@ Obtains the top ability, which is the ability that has the window focus. This AP | Type | Description | | ---------------------------------------- | ------- | -| Promise\<[ElementName](js-apis-bundleManager-elementName.md)>| Promise used to return the API call result and the element name of the top ability. You can perform error handling or custom processing in this callback.| +| Promise\<[ElementName](js-apis-bundleManager-elementName.md)>| Promise used to return the API call result and the element name of the top ability. You can perform error handling or custom processing in it.| **Error codes** @@ -383,3 +383,78 @@ abilityManager.getTopAbility().then((data) => { console.error('getTopAbility fail, err: ${JSON.stringify(err)}'); }); ``` + +## acquireShareData10+ + +acquireShareData(missionId: number, callback: AsyncCallback<{[key: string]: Object}>): void; + +Acquires the shared data of the target device. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ---------------------------------------- | ---- | -------------- | +| missionId | number | Yes| Mission ID on the target device. The maximum value is 231-1.| +| callback | AsyncCallback<{[key: string]: Object}> | Yes | Callback used to return the API call result and the shared data. You can perform error handling or custom processing in it. | + +**Error codes** + +| ID| Error Message| +| ------- | -------- | +| 16000050 | Internal error. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + +**Example** + +```ts +import abilityManager from '@ohos.app.ability.abilityManager'; + +abilityManager.acquireShareData(1, (err, wantParam) => { + if (err) { + console.error(`acquireShareData fail, err: ${JSON.stringify(err)}`); + } else { + console.log(`acquireShareData success, data: ${JSON.stringify(data)}`); + } +}); + +``` + +## acquireShareData10+ + +acquireShareData(missionId: number): Promise<{[key: string]: Object}>; + +Acquires the shared data of the target device. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Return value** + +| Type | Description | +| ---------------------------------------- | ------- | +| Promise<{[key: string]: Object}>| Promise used to return the API call result and the shared data. You can perform error handling or custom processing in it.| + +**Error codes** + +| ID| Error Message| +| ------- | -------- | +| 16000050 | Internal error. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + +**Example** + +```ts +import abilityManager from '@ohos.app.ability.abilityManager'; +try { + abilityManager.acquireShareData(1).then((wantParam) => { + console.log(`acquireShareData success, data: ${JSON.stringify(data)}`); + }).catch((err) => { + console.error(`acquireShareData fail, err: ${JSON.stringify(err)}`); + }); +} catch (paramError) { + console.error(`error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}`); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md b/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md index 6931cfe50da06cdd9b7526344a47eae29c3c8ef8..d86ca90a4576fbb67816f93749b75b670c6f24a2 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md @@ -63,8 +63,8 @@ Enables application recovery. After this API is called, the first ability that i | saveOccasion | [SaveOccasionFlag](#apprecoverysaveoccasionflag) | No| Scenario for saving the application state. By default, the state is saved when a fault occurs.| | saveMode | [SaveModeFlag](#apprecoverysavemodeflag) | No| Application state saving mode. By default, the application state is written to the local file cache.| -**Example** - +**Example** + ```ts import appRecovery from '@ohos.app.ability.appRecovery'; import AbilityStage from '@ohos.app.ability.AbilityStage'; @@ -87,19 +87,17 @@ restartApp(): void; Restarts the current process and starts the first ability that is displayed when the application is started. If the state of this ability is saved, the saved state data is passed into the **wantParam** attribute in the **want** parameter of the **OnCreate** lifecycle callback of the ability. In API version 10, the ability specified by [setRestartWant](#apprecoverysetrestartwant) is started. If no ability is specified, the following rules are used: - - If the ability of the current application running in the foreground supports recovery, that ability is started. - - If multiple abilities that support recovery is running in the foreground, only the last ability is started. - - If no ability is running in the foreground, none of them is started. This API can be used together with the APIs of [errorManager](js-apis-app-ability-errorManager.md). **System capability**: SystemCapability.Ability.AbilityRuntime.Core -**Example** +**Example** + ```ts import appRecovery from '@ohos.app.ability.appRecovery'; import errorManager from '@ohos.app.ability.errorManager'; @@ -132,8 +130,8 @@ Saves the application state. This API can be used together with the APIs of [err | -------- | -------- | | boolean | Whether the application state is saved. The value **true** is returned if the application state is saved, and **false** is returned otherwise.| -**Example** - +**Example** + ```ts import appRecovery from '@ohos.app.ability.appRecovery'; import errorManager from '@ohos.app.ability.errorManager'; @@ -160,6 +158,12 @@ Saves the ability state, which will be used for recovery. This API can be used t **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| context | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md)| No| UIAbility context.| + **Return value** | Type| Description| @@ -184,6 +188,12 @@ Sets an ability that will be recovered. The ability must be a UIAbility in the c **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-want.md)| Yes| Want of the target ability. You can set the **bundleName** and **abilityName** fields in **Want** to specify the ability.| + **Example** ```ts diff --git a/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md b/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md index 3a4ed4c5017aa7798d7df6c6bfbd1d95d8401536..a14bfa07129a2ee81705ecfecd3d9ce77756d169 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md @@ -32,12 +32,27 @@ Registers an error observer. | -------- | -------- | | number | Index of the observer.| +**Error codes** + +| ID| Error Message| +| ------- | -------- | +| 16000003 | Id does not exist. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + **Example** ```ts let observer = { onUnhandledException(errorMsg) { console.log('onUnhandledException, errorMsg: ', errorMsg); + }, + onException(errorObj) { + console.log('onException, name: ', errorObj.name); + console.log('onException, message: ', errorObj.message); + if (typeof(errorObj.stack) === 'string') { + console.log('onException, stack: ', errorObj.stack); + } } }; let observerId = -1; @@ -64,6 +79,14 @@ Deregisters an error observer. This API uses an asynchronous callback to return | observerId | number | Yes| Index of the observer returned by **on()**.| | callback | AsyncCallback\ | Yes| Callback used to return the result.| +**Error codes** + +| ID| Error Message| +| ------- | -------- | +| 16000003 | Id does not exist. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + **Example** ```ts @@ -102,6 +125,14 @@ Deregisters an error observer. This API uses a promise to return the result. | -------- | -------- | | Promise\ | Promise used to return the result.| +**Error codes** + +| ID| Error Message| +| ------- | -------- | +| 16000003 | Id does not exist. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + **Example** ```ts diff --git a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md index c041a599c6f9857db40e530f1e888c2a12f47f54..ae9420916e674279f253a621bc1d5a55f3c11290 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md @@ -148,7 +148,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal ## ServiceExtensionAbility.onDisconnect -onDisconnect(want: Want): void | Promise; +onDisconnect(want: Want): void | Promise\; Called when a client is disconnected from this ServiceExtensionAbility. diff --git a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md index fbf50f68387385c7d69c02ce599285a5b8ad2310..3a00c8056741d7658e043f0bc2083383371a2ab8 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md @@ -300,6 +300,33 @@ class MyUIAbility extends UIAbility { } ``` +## UIAbility.onShare10+ + +onShare(wantParam:{ [key: string]: Object }): void; + +Called when an ability shares data. + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| wantParam | {[key: string]: Object} | Yes| **want** parameter.| + +**Example** + + ```ts +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +class MyUIAbility extends UIAbility { + onShare(wantParams) { + console.log('onShare'); + wantParams['ohos.extra.param.key.contentTitle'] = {title: "W3"}; + wantParams['ohos.extra.param.key.shareAbstract'] = {abstract: "communication for huawei employee"}; + wantParams['ohos.extra.param.key.shareUrl'] = {url: "w3.huawei.com"}; + } +} + ``` ## Caller @@ -331,7 +358,9 @@ Sends sequenceable data to the target ability. | ID| Error Message| | ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | +| 16200001 | Caller released. The caller has been released. | +| 16200002 | Callee invalid. The callee does not exist. | +| 16000050 | Internal Error. | For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). @@ -410,7 +439,9 @@ Sends sequenceable data to the target ability and obtains the sequenceable data | ID| Error Message| | ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | +| 16200001 | Caller released. The caller has been released. | +| 16200002 | Callee invalid. The callee does not exist. | +| 16000050 | Internal Error. | For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). @@ -478,10 +509,10 @@ Releases the caller interface of the target ability. | ID| Error Message| | ------- | -------------------------------- | -| 401 | Invalid input parameter. | | 16200001 | Caller released. The caller has been released. | | 16200002 | Callee invalid. The callee does not exist. | -| 16000050 | Internal Error. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). **Example** @@ -515,6 +546,14 @@ Registers a callback that is invoked when the stub on the target ability is disc **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore +**Error codes** + +| ID| Error Message| +| ------- | -------------------------------- | +| 16200001 | Caller released. The caller has been released. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + **Parameters** | Name| Type| Mandatory| Description| @@ -538,7 +577,7 @@ Registers a callback that is invoked when the stub on the target ability is disc console.log(' Caller OnRelease CallBack is called ${str}'); }); } catch (error) { - console.log('Caller.onRelease catch error, error.code: ${error.code}, error.message: ${error.message}'); + console.log('Caller.onRelease catch error, error.code: $error.code}, error.message: ${error.message}'); } }).catch((err) => { console.log('Caller GetCaller error, error.code: ${err.code}, error.message: ${err.message}'); @@ -547,6 +586,57 @@ Registers a callback that is invoked when the stub on the target ability is disc } ``` + ## Caller.onRemoteStateChange + + onRemoteStateChange(callback: OnRemoteStateChangeCallback): void; + +Registers a callback that is invoked when the remote ability state changes in the collaboration scenario. + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | [OnRemoteStateChangeCallback](#onremotestatechangecallback) | Yes| Callback used to return the result.| + +**Error codes** + +| ID| Error Message| +| ------- | -------------------------------- | +| 16200001 | Caller released. The caller has been released. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + +**Example** + + ```ts + import UIAbility from '@ohos.app.ability.UIAbility'; + + let caller; + let dstDeviceId: string; + export default class MainAbility extends UIAbility { + onWindowStageCreate(windowStage: Window.WindowStage) { + this.context.startAbilityByCall({ + bundleName: 'com.example.myservice', + abilityName: 'MainUIAbility', + deviceId: dstDeviceId + }).then((obj) => { + caller = obj; + try { + caller.onRemoteStateChange((str) => { + console.log('Remote state changed ' + str); + }); + } catch (error) { + console.log('Caller.onRemoteStateChange catch error, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}'); + } + }).catch((err) => { + console.log('Caller GetCaller error, error.code: ${JSON.stringify(err.code)}, error.message: ${JSON.stringify(err.message)}'); + }); + } + } + ``` + ## Caller.on on(type: 'release', callback: OnReleaseCallback): void; @@ -566,7 +656,7 @@ Registers a callback that is invoked when the stub on the target ability is disc | ID| Error Message| | ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | +| 16200001 | Caller released. The caller has been released. | For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). @@ -611,13 +701,6 @@ Deregisters a callback that is invoked when the stub on the target ability is di | type | string | Yes| Event type. The value is fixed at **release**.| | callback | [OnReleaseCallback](#onreleasecallback) | Yes| Callback used to return the result.| -**Error codes** - -| ID| Error Message| -| ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | -For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md). - **Example** ```ts @@ -660,13 +743,6 @@ Deregisters a callback that is invoked when the stub on the target ability is di | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is fixed at **release**.| -**Error codes** - -| ID| Error Message| -| ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | -For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md). - **Example** ```ts @@ -718,7 +794,8 @@ Registers a caller notification callback, which is invoked when the target abili | ID| Error Message| | ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | +| 16200004 | Method registered. The method has registered. | +| 16000050 | Internal error. | For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). @@ -783,7 +860,8 @@ Deregisters a caller notification callback, which is invoked when the target abi | ID| Error Message| | ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | +| 16200005 | Method not registered. The method has not registered. | +| 16000050 | Internal error. | For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). @@ -814,6 +892,16 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error | -------- | -------- | -------- | -------- | -------- | | (msg: string) | Yes| No| function | Prototype of the listener function registered by the caller.| +## OnRemoteStateChangeCallback + +(msg: string): void; + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +| Name| Readable| Writable| Type| Description| +| -------- | -------- | -------- | -------- | -------- | +| (msg: string) | Yes| No| function | Prototype of the ability state change listener function registered by the caller in the collaboration scenario.| + ## CalleeCallback (indata: rpc.MessageSequence): rpc.Parcelable; diff --git a/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md index 03e519e65568fbbc9de2f33711c01347a12ffb4c..dd4402c9a80805dd5e4ade07fc47b78c3a6f0aa0 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md @@ -16,13 +16,17 @@ import wantConstant from '@ohos.app.ability.wantConstant'; Defines **Params** (specifying the action that can be performed) in the Want. -| Name | Value | Description | -| ----------------------- | --------------------------- | ------------------------------------------------------------ | -| DLP_PARAMS_SANDBOX | ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.
**System API**: This is a system API and cannot be called by third-party applications.| -| DLP_PARAMS_BUNDLE_NAME | ohos.dlp.params.bundleName | Action of obtaining the DLP bundle name.
**System API**: This is a system API and cannot be called by third-party applications.| -| DLP_PARAMS_MODULE_NAME | ohos.dlp.params.moduleName | Action of obtaining the DLP module name.
**System API**: This is a system API and cannot be called by third-party applications.| -| DLP_PARAMS_ABILITY_NAME | ohos.dlp.params.abilityName | Action of obtaining the DLP ability name.
**System API**: This is a system API and cannot be called by third-party applications.| -| DLP_PARAMS_INDEX | ohos.dlp.params.index | Action of obtaining the DLP index.
**System API**: This is a system API and cannot be called by third-party applications.| +| Name | Value | Description | +| ----------------------- | ---------------------------------- | ------------------------------------------------------------------------------ | +| DLP_PARAMS_SANDBOX | ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.
**System API**: This is a system API and cannot be called by third-party applications.| +| DLP_PARAMS_BUNDLE_NAME | ohos.dlp.params.bundleName | Action of obtaining the DLP bundle name.
**System API**: This is a system API and cannot be called by third-party applications.| +| DLP_PARAMS_MODULE_NAME | ohos.dlp.params.moduleName | Action of obtaining the DLP module name.
**System API**: This is a system API and cannot be called by third-party applications.| +| DLP_PARAMS_ABILITY_NAME | ohos.dlp.params.abilityName | Action of obtaining the DLP ability name.
**System API**: This is a system API and cannot be called by third-party applications.| +| DLP_PARAMS_INDEX | ohos.dlp.params.index | Action of obtaining the DLP index.
**System API**: This is a system API and cannot be called by third-party applications.| +| ABILITY_RECOVERY_RESTART | ohos.ability.params.abilityRecoveryRestart | Action of recovering an ability from a fault and restarting it.| +| CONTENT_TITLE_KEY | ohos.extra.param.key.contentTitle | Action of sharing the content title.
**System API**: This is a system API and cannot be called by third-party applications.| +| SHARE_ABSTRACT_KEY | ohos.extra.param.key.shareAbstract | Action of sharing the abstract.
**System API**: This is a system API and cannot be called by third-party applications.| +| SHARE_URL_KEY | ohos.extra.param.key.shareUrl | Action of sharing the URL.
**System API**: This is a system API and cannot be called by third-party applications.| ## wantConstant.Flags diff --git a/en/application-dev/reference/apis/js-apis-avsession.md b/en/application-dev/reference/apis/js-apis-avsession.md index b89eb42bc8793b9d28f1682ab87b1ac9f157c14d..7efa6349694569c43954930e8fafdb8046a2446c 100644 --- a/en/application-dev/reference/apis/js-apis-avsession.md +++ b/en/application-dev/reference/apis/js-apis-avsession.md @@ -449,8 +449,9 @@ For details about the error codes, see [AVSession Management Error Codes](../err import audio from '@ohos.multimedia.audio'; let audioManager = audio.getAudioManager(); +let audioRoutingManager = audioManager.getRoutingManager(); let audioDevices; -await audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { +await audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { audioDevices = data; console.info('Promise returned to indicate that the device list is obtained.'); }).catch((err) => { @@ -502,8 +503,9 @@ For details about the error codes, see [AVSession Management Error Codes](../err import audio from '@ohos.multimedia.audio'; let audioManager = audio.getAudioManager(); +let audioRoutingManager = audioManager.getRoutingManager(); let audioDevices; -await audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { +await audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { audioDevices = data; console.info('Promise returned to indicate that the device list is obtained.'); }).catch((err) => { diff --git a/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md b/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md index 3687950d91688181565b8f8cb01f8538e9e77489..10dd9ae0285353e3feca2647ff4eee0dfce490b6 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md @@ -88,7 +88,7 @@ export default class EntryAbility extends UIAbility { } ``` -## ApplicationContext.off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback) +## ApplicationContext.off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback\) off(type: 'abilityLifecycle', callbackId: **number**, callback: AsyncCallback<**void**>): **void**; @@ -116,7 +116,7 @@ export default class EntryAbility extends UIAbility { let applicationContext = this.context.getApplicationContext(); console.log('stage applicationContext: ${applicationContext}'); applicationContext.off('abilityLifecycle', lifecycleId, (error, data) => { - if (error && error.code !== 0) { + if (error) { console.error('unregisterAbilityLifecycleCallback fail, err: ${JSON.stringify(error)}'); } else { console.log('unregisterAbilityLifecycleCallback success, data: ${JSON.stringify(data)}'); @@ -206,7 +206,7 @@ export default class EntryAbility extends UIAbility { } ``` -## ApplicationContext.off(type: 'environment', callbackId: number, callback: AsyncCallback) +## ApplicationContext.off(type: 'environment', callbackId: number, callback: AsyncCallback\) off(type: 'environment', callbackId: **number**, callback: AsyncCallback<**void**>): **void**; @@ -233,7 +233,7 @@ export default class EntryAbility extends UIAbility { onDestroy() { let applicationContext = this.context.getApplicationContext(); applicationContext.off('environment', callbackId, (error, data) => { - if (error && error.code !== 0) { + if (error) { console.error('unregisterEnvironmentCallback fail, err: ${JSON.stringify(error)}'); } else { console.log('unregisterEnvironmentCallback success, data: ${JSON.stringify(data)}'); @@ -291,6 +291,15 @@ Obtains information about the running processes. This API uses a promise to retu | -------- | -------- | | Promise\> | Promise used to return the API call result and the process running information. You can perform error handling or custom processing in this callback.| +**Error codes** + +| ID| Error Message| +| ------- | -------- | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + **Example** ```ts @@ -320,12 +329,21 @@ Obtains information about the running processes. This API uses an asynchronous c | -------- | -------- | |AsyncCallback\> | Callback used to return the API call result and the process running information. You can perform error handling or custom processing in this callback.| +**Error codes** + +| ID| Error Message| +| ------- | -------- | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + **Example** ```ts let applicationContext = this.context.getApplicationContext(); applicationContext.getRunningProcessInformation((err, data) => { - if (err.code !== 0) { + if (err) { console.error('getRunningProcessInformation faile, err: ${JSON.stringify(err)}'); } else { console.log('The process running information is: ${JSON.stringify(data)}'); @@ -347,6 +365,14 @@ Kills all the processes where the application is located. This API uses a promis | -------- | -------- | | Promise\ | Promise used to return the result.| +**Error codes** + +| ID| Error Message| +| ------- | -------- | +| 16000011 | The context does not exist. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + **Example** ```ts @@ -368,12 +394,20 @@ Kills all the processes where the application is located. This API uses an async | -------- | -------- | |AsyncCallback\ | Callback used to return the result.| +**Error codes** + +| ID| Error Message| +| ------- | -------- | +| 16000011 | The context does not exist. | + +For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). + **Example** ```ts let applicationContext = this.context.getApplicationContext(); applicationContext.killAllProcesses(error => { - if (error && error.code !== 0) { + if (error) { console.error('killAllProcesses fail, error: ${JSON.stringify(error)}'); } }); diff --git a/en/application-dev/reference/apis/js-apis-inner-application-errorObserver.md b/en/application-dev/reference/apis/js-apis-inner-application-errorObserver.md index 43771f06405de4d48c6b3831a5bf853b12bd9bca..095529fabba54410949261e8ed9d64da620a4d89 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-errorObserver.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-errorObserver.md @@ -2,6 +2,12 @@ The **ErrorObserver** module defines an observer to listen for application errors. It can be used as an input parameter in [ErrorManager.on](js-apis-app-ability-errorManager.md#errormanageron) to listen for errors that occur in the current application. +## Modules to Import + +```ts +import errorManager from '@ohos.app.ability.errorManager'; +``` + ## ErrorObserver.onUnhandledException onUnhandledException(errMsg: string): void; @@ -33,3 +39,42 @@ try { console.error('registerErrorObserver failed, error.code: ${error.code}, error.message: ${error.message}'); } ``` + +## ErrorObserver.onException + +onException?(errObject: Error): void; + +Called when an exception occurs during the application running. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| errObject | Error | Yes| Event name, message, and error stack of the exception.| + +**Example** + +```ts +import errorManager from '@ohos.app.ability.errorManager'; + +let observer = { + onUnhandledException(errorMsg) { + console.error('onUnhandledException, errorMsg: ', errorMsg); + }, + onException(errorObj) { + console.log('onException, name: ', errorObj.name); + console.log('onException, message: ', errorObj.message); + if (typeof(errorObj.stack) === 'string') { + console.log('onException, stack: ', errorObj.stack); + } + } +}; + +try { + errorManager.on('error', observer); +} catch (error) { + console.error('registerErrorObserver failed, error.code: ${error.code}, error.message: ${error.message}'); +} +```