提交 ed84c4a8 编写于 作者: M mingxihua

mingxihua@huawei.com.cn

Signed-off-by: Nmingxihua <mingxihua@huawei.com>
上级 4a4cf974
......@@ -57,8 +57,12 @@ featureAbility.startAbility(
uri: ''
},
},
(err, data) => {
console.info('startAbility err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
(error, data) => {
if (error && error.code !== 0) {
console.error('startAbility fail, error: ${JSON.stringify(error)}');
} else {
console.log('startAbility success, data: ${JSON.stringify(data)}');
}
}
);
```
......@@ -193,8 +197,12 @@ featureAbility.startAbilityForResult(
uri:''
},
},
(err, data) => {
console.info('startAbilityForResult err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
(error, data) => {
if (error && error.code !== 0) {
console.error('startAbilityForResult fail, error: ${JSON.stringify(error)}');
} else {
console.log('startAbilityForResult success, data: ${JSON.stringify(data)}');
}
}
);
```
......@@ -309,8 +317,8 @@ featureAbility.terminateSelfWithResult(
}
},
},
(err) => {
console.error('err: ${JSON.stringify(err)}');
(error) => {
console.error('error: ${JSON.stringify(error)}');
}
);
```
......@@ -389,8 +397,12 @@ hasWindowFocus(callback: AsyncCallback\<boolean>): void
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus((err, data) => {
console.info('hasWindowFocus err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
featureAbility.hasWindowFocus((error, data) => {
if (error && error.code !== 0) {
console.error('hasWindowFocus fail, error: ${JSON.stringify(error)}');
} else {
console.log('hasWindowFocus success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -435,8 +447,12 @@ getWant(callback: AsyncCallback\<Want>): void
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant((err, data) => {
console.info('getWant err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
featureAbility.getWant((error, data) => {
if (error && error.code !== 0) {
console.error('getWant fail, error: ${JSON.stringify(error)}');
} else {
console.log('getWant success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -482,8 +498,12 @@ getContext(): Context
```ts
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getBundleName((err, data) => {
console.info('getBundleName err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}');
context.getBundleName((error, data) => {
if (error && error.code !== 0) {
console.error('getBundleName fail, error: ${JSON.stringify(error)}');
} else {
console.log('getBundleName success, data: ${JSON.stringify(data)}');
}
});
```
......@@ -506,8 +526,8 @@ terminateSelf(callback: AsyncCallback\<void>): void
```ts
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf(
(err) => {
console.error('err: ${JSON.stringify(err)}');
(error) => {
console.error('error: ${JSON.stringify(error)}');
}
)
```
......@@ -574,7 +594,7 @@ function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}')
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}')
console.error('featureAbilityTest ConnectAbility onFailed errCode : ${code}')
}
let connectId = featureAbility.connectAbility(
{
......@@ -617,7 +637,7 @@ function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
console.error('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
}
let connectId = featureAbility.connectAbility(
{
......@@ -631,8 +651,12 @@ let connectId = featureAbility.connectAbility(
},
);
featureAbility.disconnectAbility(connectId, (err) => {
console.error('featureAbilityTest disconnectAbility err: ${JSON.stringify(err)}');
featureAbility.disconnectAbility(connectId, (error) => {
if (error && error.code !== 0) {
console.error('disconnectAbility fail, connectId: ${connectId}, error: ${JSON.stringify(error)}');
} else {
console.log('disconnectAbility success, connectId: ${connectId}');
}
});
```
......@@ -668,7 +692,7 @@ function onDisconnectCallback(element){
console.log('ConnectAbility onDisconnect element.deviceId : ${element.deviceId}');
}
function onFailedCallback(code){
console.log('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
console.error('featureAbilityTest ConnectAbility onFailed errCode : ${code}');
}
let connectId = featureAbility.connectAbility(
{
......@@ -707,8 +731,12 @@ getWindow(callback: AsyncCallback\<window.Window>): void
**示例:**
```ts
featureAbility.getWindow((err, data) => {
console.info('getWindow err: ${JSON.stringify(err)}, data: ${typeof(data)}');
featureAbility.getWindow((error, data) => {
if (error && error.code !== 0) {
console.error('getWindow fail, error: ${JSON.stringify(error)}');
} else {
console.log('getWindow success, data: ${JSON.stringify(data)}');
}
});
```
......
......@@ -57,8 +57,12 @@ particleAbility.startAbility(
uri: ''
},
},
(error, result) => {
console.error('particleAbility startAbility errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
(error, data) => {
if (error && error.code !== 0) {
console.error('startAbility fail, error: ${JSON.stringify(error)}');
} else {
console.log('startAbility success, data: ${JSON.stringify(data)}');
}
},
);
```
......@@ -133,8 +137,12 @@ terminateSelf(callback: AsyncCallback\<void>): void
import particleAbility from '@ohos.ability.particleAbility';
particleAbility.terminateSelf(
(error, result) => {
console.log('particleAbility terminateSelf errCode: ${JSON.stringify(error)}, result: ${JSON.stringify(result)}');
(error, data) => {
if (error && error.code !== 0) {
console.error('terminateSelf fail, error: ${JSON.stringify(error)}');
} else {
console.log('terminateSelf success, data: ${JSON.stringify(data)}');
}
}
);
```
......@@ -226,11 +234,11 @@ import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.app.ability.wantAgent';
function callback(err, data) {
if (err) {
console.error('Operation failed cause: ${JSON.stringify(err)}');
function callback(error, data) {
if (error && error.code !== 0) {
console.error('Operation failed error: ${JSON.stringify(error)}');
} else {
console.info('Operation succeeded');
console.info('Operation succeeded, data: ${data}');
}
}
......@@ -349,11 +357,11 @@ cancelBackgroundRunning(callback: AsyncCallback&lt;void&gt;): void;
```ts
import particleAbility from '@ohos.ability.particleAbility';
function callback(err, data) {
if (err) {
console.error('Operation failed cause: ${JSON.stringify(err)}');
function callback(error, data) {
if (error && error.code !== 0) {
console.error('Operation failed error: ${JSON.stringify(error)}');
} else {
console.info('Operation succeeded');
console.info('Operation succeeded, data: ${data}');
}
}
......
......@@ -41,10 +41,10 @@ export default class EntryAbility extends UIAbility {
windowStage.loadContent('pages/index', (err, data) => {
if (err.code) {
console.error('failed to load the content, error: + ${JSON.stringify(err)}');
console.error('failed to load the content, error: ${JSON.stringify(err)}');
return;
}
console.info('Succeeded in loading the content, data: + ${JSON.stringify(data)}');
console.info('Succeeded in loading the content, data: ${JSON.stringify(data)}');
});
}
}
......
......@@ -83,7 +83,7 @@ export default class EntryAbility extends UIAbility {
let applicationContext = this.context.getApplicationContext();
// 2.通过applicationContext注册监听应用内生命周期
lifecycleId = applicationContext.on('abilityLifecycle', AbilityLifecycleCallback);
console.log('registerAbilityLifecycleCallback number: ' + JSON.stringify(lifecycleId));
console.log('registerAbilityLifecycleCallback lifecycleId: ${lifecycleId)}');
}
}
```
......@@ -114,9 +114,13 @@ let lifecycleId;
export default class EntryAbility extends UIAbility {
onDestroy() {
let applicationContext = this.context.getApplicationContext();
console.log('stage applicationContext: ' + applicationContext);
console.log('stage applicationContext: ${applicationContext}');
applicationContext.off(type: 'abilityLifecycle', lifecycleId, (error, data) => {
console.log('unregisterAbilityLifecycleCallback success, err: ' + JSON.stringify(error));
if (error && error.code !== 0) {
console.error('unregisterAbilityLifecycleCallback fail, err: ${JSON.stringify(error)}');
} else {
console.log('unregisterAbilityLifecycleCallback success, data: ${JSON.stringify(data)}');
}
});
}
}
......@@ -147,7 +151,7 @@ let lifecycleId;
export default class MyAbility extends Ability {
onDestroy() {
let applicationContext = this.context.getApplicationContext();
console.log('stage applicationContext: ' + applicationContext);
console.log('stage applicationContext: ${applicationContext}');
applicationContext.off(type: 'abilityLifecycle', lifecycleId);
}
}
......@@ -185,19 +189,19 @@ export default class EntryAbility extends UIAbility {
onCreate() {
console.log('MyAbility onCreate')
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
let environmentCallback = {
onConfigurationUpdated(config){
console.log('onConfigurationUpdated config:' + JSON.stringify(config));
console.log('onConfigurationUpdated config: ${JSON.stringify(config)}');
},
onMemoryLevel(level){
console.log('onMemoryLevel level:' + level);
console.log('onMemoryLevel level: ${level}');
}
}
};
// 1.获取applicationContext
let applicationContext = globalThis.applicationContext;
// 2.通过applicationContext注册监听应用内生命周期
callbackId = applicationContext.on('environment', EnvironmentCallback);
console.log('registerEnvironmentCallback number: ' + JSON.stringify(callbackId));
// 2.通过applicationContext注册监听系统环境变化
callbackId = applicationContext.on('environment', environmentCallback);
console.log('registerEnvironmentCallback callbackId: ${callbackId}');
}
}
```
......@@ -229,7 +233,11 @@ export default class EntryAbility extends UIAbility {
onDestroy() {
let applicationContext = this.context.getApplicationContext();
applicationContext.off('environment', callbackId, (error, data) => {
console.log('unregisterEnvironmentCallback success, err: ' + JSON.stringify(error));
if (error && error.code !== 0) {
console.error('unregisterEnvironmentCallback fail, err: ${JSON.stringify(error)}');
} else {
console.log('unregisterEnvironmentCallback success, data: ${JSON.stringify(data)}');
}
});
}
}
......
......@@ -1916,7 +1916,7 @@ setMissionLabel(label: string): Promise&lt;void&gt;;
setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void;
设置当前ability在任务中显示的图标(callback形式)。
设置当前ability在任务中显示的图标, 图标大小最大为600M(callback形式)。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
......@@ -1966,7 +1966,7 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void;
setMissionIcon(icon: image.PixelMap): Promise\<void>;
设置当前ability在任务中显示的图标(promise形式)。
设置当前ability在任务中显示的图标, 图标大小最大为600M(promise形式)。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
......@@ -2112,7 +2112,7 @@ try {
return;
}
// 执行正常业务
console.info('requestDialogService succeed, result = ' + JSON.stringify(result));
console.info('requestDialogService succeed, result = ${JSON.stringify(result)}');
});
} catch (err) {
// 处理入参错误异常
......@@ -2160,7 +2160,7 @@ try {
this.context.requestDialogService(want)
.then((result) => {
// 执行正常业务
console.info('requestDialogService succeed, result = ' + JSON.stringify(result));
console.info('requestDialogService succeed, result = ${JSON.stringify(result)}');
})
.catch((err) => {
// 处理业务逻辑错误
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册