未验证 提交 6be7a7c2 编写于 作者: O openharmony_ci 提交者: Gitee

!17211 update err

Merge pull request !17211 from xieqiongyang/master
......@@ -53,10 +53,10 @@ let want = {
abilityName: 'EntryAbility'
};
abilityDelegator.startAbility(want, (err) => {
if (!err || err.code === 0) {
console.log('Success start ability.');
} else {
if (err) {
console.error('Failed start ability, error: ${JSON.stringify(err)}');
} else {
console.log('Success start ability.');
}
});
```
......
......@@ -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.');
......@@ -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)}');
......@@ -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)}');
......@@ -342,7 +342,7 @@ getTopAbility(callback: AsyncCallback\<ElementName>): void;
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)}');
......@@ -413,7 +413,7 @@ acquireShareData(missionId: number, callback: AsyncCallback<{[key: string]: Obje
import abilityManager from '@ohos.app.ability.abilityManager';
abilityManager.acquireShareData(1, (err, wantParam) => {
if (err && err.code !== 0) {
if (err) {
console.error('acquireShareData fail, err: ${JSON.stringify(err)}');
} else {
console.log('acquireShareData success, data: ${JSON.stringify(data)}');
......
......@@ -40,7 +40,7 @@ static isRunningInStabilityTest(callback: AsyncCallback&lt;boolean&gt;): void
import appManager from '@ohos.app.ability.appManager';
appManager.isRunningInStabilityTest((err, flag) => {
if (err && err.code !== 0) {
if (err) {
console.error('isRunningInStabilityTest fail, err: ${JSON.stringify(err)}');
} else {
console.log('The result of isRunningInStabilityTest is: ${JSON.stringify(flag)}');
......@@ -146,7 +146,7 @@ isRamConstrainedDevice(callback: AsyncCallback\<boolean>): void;
import appManager from '@ohos.app.ability.appManager';
appManager.isRamConstrainedDevice((err, data) => {
if (err && err.code !== 0) {
if (err) {
console.error('isRamConstrainedDevice fail, err: ${JSON.stringify(err)}');
} else {
console.log('The result of isRamConstrainedDevice is: ${JSON.stringify(data)}');
......@@ -216,7 +216,7 @@ getAppMemorySize(callback: AsyncCallback\<number>): void;
import appManager from '@ohos.app.ability.appManager';
appManager.getAppMemorySize((err, data) => {
if (err && err.code !== 0) {
if (err) {
console.error('getAppMemorySize fail, err: ${JSON.stringify(err)}');
} else {
console.log('The size of app memory is: ${JSON.stringify(data)}');
......@@ -290,7 +290,7 @@ getRunningProcessInformation(callback: AsyncCallback\<Array\<ProcessInformation>
import appManager from '@ohos.app.ability.appManager';
appManager.getRunningProcessInformation((err, data) => {
if (err && err.code !== 0) {
if (err) {
console.error('getRunningProcessInformation fail, err: ${JSON.stringify(err)}');
} else {
console.log('The process running information is: ${JSON.stringify(data)}');
......@@ -489,7 +489,7 @@ try {
// 2.注销应用状态监听器
function unregisterApplicationStateObserverCallback(err) {
if (err && err.code !== 0) {
if (err) {
console.error('unregisterApplicationStateObserverCallback fail, err: ${JSON.stringify(err)}');
} else {
console.log('unregisterApplicationStateObserverCallback success.');
......@@ -612,7 +612,7 @@ getForegroundApplications(callback: AsyncCallback\<Array\<AppStateData>>): void;
import appManager from '@ohos.app.ability.appManager';
function getForegroundApplicationsCallback(err, data) {
if (err && err.code !== 0) {
if (err) {
console.error('getForegroundApplicationsCallback fail, err: ${JSON.stringify(err)}');
} else {
console.log('getForegroundApplicationsCallback success, data: ${JSON.stringify(data)}');
......@@ -745,7 +745,7 @@ import appManager from '@ohos.app.ability.appManager';
let bundleName = 'bundleName';
let accountId = 0;
function killProcessWithAccountCallback(err, data) {
if (err && err.code !== 0) {
if (err) {
console.error('killProcessWithAccountCallback fail, err: ${JSON.stringify(err)}');
} else {
console.log('killProcessWithAccountCallback success.');
......@@ -788,7 +788,7 @@ import appManager from '@ohos.app.ability.appManager';
let bundleName = 'bundleName';
function killProcessesByBundleNameCallback(err, data) {
if (err && err.code !== 0) {
if (err) {
console.error('killProcessesByBundleNameCallback fail, err: ${JSON.stringify(err)}');
} else {
console.log('killProcessesByBundleNameCallback success.');
......@@ -884,7 +884,7 @@ import appManager from '@ohos.app.ability.appManager';
let bundleName = 'bundleName';
function clearUpApplicationDataCallback(err, data) {
if (err && err.code !== 0) {
if (err) {
console.error('clearUpApplicationDataCallback fail, err: ${JSON.stringify(err)}');
} else {
console.log('clearUpApplicationDataCallback success.');
......
......@@ -32,12 +32,12 @@ import StartOptions from '@ohos.app.ability.StartOptions';
try {
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
if (error) {
console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
console.log('size = ${missions.length}');
console.log('missions = ${JSON.stringify(missions)}');
console.log(`size = ${missions.length}`);
console.log(`missions = ${JSON.stringify(missions)}`);
let id = missions[0].missionId;
let startOptions = {
......@@ -45,10 +45,10 @@ import StartOptions from '@ohos.app.ability.StartOptions';
displayId: 0
};
missionManager.moveMissionToFront(id, startOptions).then(() => {
console.log('moveMissionToFront is called ');
console.log('moveMissionToFront is called');
});
});
} catch (paramError) {
console.error('error: ${paramError.code}, ${paramError.message}');
console.error(`error: ${paramError.code}, ${paramError.message}`);
}
```
......@@ -196,7 +196,7 @@ let monitor = {
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityMonitor(monitor, (error : any, data : any) => {
if (error && error.code !== 0) {
if (error) {
console.error('waitAbilityMonitor fail, error: ${JSON.stringify(error)}');
} else {
console.log('waitAbilityMonitor success, data: ${JSON.stringify(data)}');
......
......@@ -45,7 +45,7 @@ let monitor = {
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityMonitor(monitor, (error : any) => {
if (error && error.code !== 0) {
if (error) {
console.error('addAbilityMonitor fail, error: ${JSON.stringify(error)}');
}
});
......
......@@ -31,7 +31,7 @@ AbilityRunningInfo模块提供对Ability运行的相关信息和状态的定义
import abilitymanager from '@ohos.app.ability.abilityManager';
abilitymanager.getAbilityRunningInfos((error, data) => {
if (error && error.code !== 0) {
if (error) {
console.error('getAbilityRunningInfos fail, error: ${JSON.stringify(error)}');
} else {
console.log('getAbilityRunningInfos success, data: ${JSON.stringify(data)}');
......
......@@ -20,7 +20,7 @@ let monitor = {
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityStageMonitor(monitor, (error, data) => {
if (error && error.code !== 0) {
if (error) {
console.error('waitAbilityStageMonitor fail, error: ${JSON.stringify(error)}');
} else {
console.log('waitAbilityStageMonitor success, data: ${JSON.stringify(data)}');
......
# AppStateData
# AppStateData
定义应用状态信息,可以通过[getForegroundApplications](js-apis-app-ability-appManager.md#appmanagergetforegroundapplications)获取当前应用的相关信息。
......@@ -19,7 +19,7 @@ import appManager from '@ohos.app.ability.appManager';
function getForegroundAppInfos() {
appManager.getForegroundApplications((error, data) => {
if (error && error.code) {
if (error) {
console.log('getForegroundApplications failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
......
......@@ -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)}');
......@@ -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)}');
......@@ -325,7 +325,7 @@ getRunningProcessInformation(callback: AsyncCallback\<Array\<ProcessInformation>
```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)}');
......@@ -373,7 +373,7 @@ killAllProcesses(callback: AsyncCallback\<void\>);
```ts
let applicationContext = this.context.getApplicationContext();
applicationContext.killAllProcesses(error => {
if (error && error.code !== 0) {
if (error) {
console.error('killAllProcesses fail, error: ${JSON.stringify(error)}');
}
});
......
......@@ -32,7 +32,7 @@ import abilityManager from '@ohos.app.ability.abilityManager';
let upperLimit = 1;
function getExtensionInfos() {
abilityManager.getExtensionRunningInfos(upperLimit, (error, data) => {
if (error && error.code) {
if (error) {
console.error('getForegroundApplications failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
......
......@@ -23,7 +23,7 @@ import missionManager from '@ohos.app.ability.missionManager';
try {
missionManager.getMissionInfo('', 1, (error, data) => {
if (error.code) {
if (error) {
// 处理业务逻辑错误
console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}');
return;
......
......@@ -26,7 +26,7 @@
try {
missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) {
if (error) {
console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}');
return;
}
......@@ -35,7 +35,7 @@
let id = missions[0].missionId;
missionManager.getMissionSnapShot('', id, (err, snapshot) => {
if (err.code) {
if (err) {
console.error('getMissionInfos failed, err.code: ${err.code}, err.message: ${err.message}');
return;
}
......
......@@ -14,7 +14,7 @@ ProcessInformation模块提供对进程运行信息进行查询的能力。
import appManager from '@ohos.app.ability.appManager';
appManager.getRunningProcessInformation((error, data) => {
if (error && error.code !== 0) {
if (error) {
console.error('getRunningProcessInformation fail, error: ${JSON.stringify(error)}');
} else {
console.log('getRunningProcessInformation success, data: ${JSON.stringify(data)}');
......
......@@ -25,7 +25,7 @@ let cmd = 'cmd';
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, (error: any, data: any) => {
if (error && error.code !== 0) {
if (error) {
console.error('executeShellCommand fail, error: ${JSON.stringify(error)}');
} else {
console.log('executeShellCommand success, data: ${JSON.stringify(data)}');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册