From 5ab746c7beec87e40b0c4061129df95f2c7bc57d Mon Sep 17 00:00:00 2001 From: donglin Date: Mon, 16 Jan 2023 12:53:05 +0000 Subject: [PATCH] =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donglin Change-Id: Iecbf0e576f90fc5a4f004da8cbcf7c9ad1fd8f1e --- ...pis-app-ability-abilityDelegatorRegistry.md | 2 +- ...pis-app-ability-abilityLifecycleCallback.md | 2 +- .../apis/js-apis-app-ability-abilityManager.md | 8 ++++---- .../apis/js-apis-app-ability-appManager.md | 18 +++++++++--------- .../js-apis-inner-application-errorObserver.md | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md index a55ac9b04c..2140dfe23e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md @@ -53,7 +53,7 @@ let want = { abilityName: "EntryAbility" }; abilityDelegator.startAbility(want, (err) => { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("Success start ability."); } else { console.log("Failed start ability, error: " + JSON.stringify(err)); diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md index 919cbce9d3..6c9f3708c4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md @@ -292,7 +292,7 @@ export default class MySecondAbility extends UIAbility { let applicationContext = this.context.getApplicationContext(); // 3.通过applicationContext注销监听应用内生命周期 applicationContext.off("abilityLifecycle", globalThis.lifecycleId, (error) => { - if (error.code != 0) { + if (error && error.code != 0) { console.log("unregisterAbilityLifecycleCallback failed, error: " + JSON.stringify(error)); } else { console.log("unregisterAbilityLifecycleCallback success."); diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md index 2ca889c93f..4bed823cf2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md @@ -70,7 +70,7 @@ const config = { try { abilityManager.updateConfiguration(config, (err) => { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("updateConfiguration fail, err: " + JSON.stringify(err)); } else { console.log("updateConfiguration success."); @@ -169,7 +169,7 @@ import abilityManager from '@ohos.app.ability.abilityManager'; try { abilityManager.getAbilityRunningInfos((err, data) => { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("getAbilityRunningInfos fail, error: " + JSON.stringify(err)); } else { console.log("getAbilityRunningInfos success, data: " + JSON.stringify(data)); @@ -256,7 +256,7 @@ let upperLimit = 10; try { abilityManager.getExtensionRunningInfos(upperLimit, (err, data) => { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("getExtensionRunningInfos fail, err: " + JSON.stringify(err)); } else { console.log("getExtensionRunningInfos success, data: " + JSON.stringify(data)); @@ -345,7 +345,7 @@ getTopAbility(callback: AsyncCallback\): void; import abilityManager from '@ohos.app.ability.abilityManager'; abilityManager.getTopAbility((err, data) => { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("getTopAbility fail, err: " + JSON.stringify(err)); } else { console.log("getTopAbility success, data: " + JSON.stringify(data)); diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md index 34cec4de8b..5f57b87f00 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md @@ -40,7 +40,7 @@ static isRunningInStabilityTest(callback: AsyncCallback<boolean>): void import appManager from '@ohos.app.ability.appManager'; appManager.isRunningInStabilityTest((err, flag) => { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("isRunningInStabilityTest faile, err: " + JSON.stringify(err)); } else { console.log("The result of isRunningInStabilityTest is:" + JSON.stringify(flag)); @@ -146,7 +146,7 @@ isRamConstrainedDevice(callback: AsyncCallback\): void; import appManager from '@ohos.app.ability.appManager'; appManager.isRamConstrainedDevice((err, data) => { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("isRamConstrainedDevice faile, err: " + JSON.stringify(err)); } else { console.log("The result of isRamConstrainedDevice is:" + JSON.stringify(data)); @@ -216,7 +216,7 @@ getAppMemorySize(callback: AsyncCallback\): void; import appManager from '@ohos.app.ability.appManager'; appManager.getAppMemorySize((err, data) => { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("getAppMemorySize faile, err: " + JSON.stringify(err)); } else { console.log("The size of app memory is:" + JSON.stringify(data)); @@ -294,7 +294,7 @@ getProcessRunningInformation(callback: AsyncCallback\ { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("getProcessRunningInformation faile, err: " + JSON.stringify(err)); } else { console.log("The process running information is:" + JSON.stringify(data)); @@ -493,7 +493,7 @@ try { // 2.注销应用状态监听器 function unregisterApplicationStateObserverCallback(err) { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("unregisterApplicationStateObserverCallback faile, err: " + JSON.stringify(err)); } else { console.log("unregisterApplicationStateObserverCallback success."); @@ -616,7 +616,7 @@ getForegroundApplications(callback: AsyncCallback\>): void; import appManager from '@ohos.app.ability.appManager'; function getForegroundApplicationsCallback(err, data) { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("getForegroundApplicationsCallback fail, err: " + JSON.stringify(err)); } else { console.log("getForegroundApplicationsCallback success, data: " + JSON.stringify(data)); @@ -749,7 +749,7 @@ import appManager from '@ohos.app.ability.appManager'; let bundleName = 'bundleName'; let accountId = 0; function killProcessWithAccountCallback(err, data) { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("killProcessWithAccountCallback fail, err: " + JSON.stringify(err)); } else { console.log("killProcessWithAccountCallback success."); @@ -792,7 +792,7 @@ import appManager from '@ohos.app.ability.appManager'; let bundleName = 'bundleName'; function killProcessesByBundleNameCallback(err, data) { - if (err.code !== 0) { + if (err && err.code !== 0) { console.log("killProcessesByBundleNameCallback fail, err: " + JSON.stringify(err)); } else { console.log("killProcessesByBundleNameCallback success."); @@ -888,7 +888,7 @@ import appManager from '@ohos.app.ability.appManager'; let bundleName = 'bundleName'; function clearUpApplicationDataCallback(err, data) { - if (err) { + if (err && err.code !== 0) { console.log("clearUpApplicationDataCallback fail, err: " + JSON.stringify(err)); } else { console.log("clearUpApplicationDataCallback success."); diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md index 825a459c7e..7623681bb8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md @@ -19,11 +19,11 @@ onUnhandledException(errMsg: string): void; **示例:** ```ts -import errorManager from '@ohos.app.ability.errorManager' +import errorManager from '@ohos.app.ability.errorManager'; let observer = { onUnhandledException(errorMsg) { - console.log('HXW onUnhandledException, errorMsg: ', errorMsg); + console.log('onUnhandledException, errorMsg: ', errorMsg); } } -- GitLab