提交 71d56381 编写于 作者: G Gloria

Update docs against 8751+8711+8895

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 b3cc15a8
......@@ -108,7 +108,9 @@ To create Page abilities for an application in the stage model, you must impleme
}
```
### Obtaining AbilityStage and Ability Configurations
Both the `AbilityStage` and `Ability` classes have the `context` attribute. An application can obtain the context of an `Ability` instance through `this.context` to obtain the configuration details. The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `AbilityStage` class. The sample code is as follows:
Both the `AbilityStage` and `Ability` classes have the `context` attribute. An application can obtain the context of an `Ability` instance through `this.context` to obtain the configuration details.
The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `AbilityStage` class. The sample code is as follows:
```ts
import AbilityStage from "@ohos.application.AbilityStage"
......@@ -123,7 +125,7 @@ export default class MyAbilityStage extends AbilityStage {
console.log("MyAbilityStage hap module mainAbilityName" + currentHapModuleInfo.mainAbilityName)
let config = this.context.config
console.log("MainAbility config language" + config.language)
console.log("MyAbilityStage config language" + config.language)
}
}
```
......@@ -142,7 +144,7 @@ export default class MainAbility extends Ability {
console.log("MainAbility ability name" + abilityInfo.name)
let config = this.context.config
console.log("MainAbility config language" + config.language)
console.log("MyAbilityStage config language" + config.language)
}
}
```
......
......@@ -127,7 +127,7 @@ Starts an ability. This API uses a promise to return the result.
windowMode: 0,
};
this.context.startAbility(want, options)
.then((data) => {
.then(() => {
console.log('Operation successful.')
}).catch((error) => {
console.log('Operation failed.');
......@@ -407,8 +407,8 @@ Starts a new Service Extension ability. This API uses a promise to return the re
"abilityName": "MainAbility"
};
this.context.startServiceExtensionAbility(want)
.then((data) => {
console.log('---------- startServiceExtensionAbility success, data: -----------', data);
.then(() => {
console.log('---------- startServiceExtensionAbility success -----------');
})
.catch((err) => {
console.log('---------- startServiceExtensionAbility fail, err: -----------', err);
......@@ -477,8 +477,8 @@ Starts a new Service Extension ability with the account ID specified. This API u
};
var accountId = 100;
this.context.startServiceExtensionAbilityWithAccount(want,accountId)
.then((data) => {
console.log('---------- startServiceExtensionAbilityWithAccount success, data: -----------', data);
.then(() => {
console.log('---------- startServiceExtensionAbilityWithAccount success -----------');
})
.catch((err) => {
console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err);
......@@ -539,8 +539,8 @@ Stops a Service Extension ability in the same application. This API uses a promi
"abilityName": "MainAbility"
};
this.context.stopServiceExtensionAbility(want)
.then((data) => {
console.log('---------- stopServiceExtensionAbility success, data: -----------', data);
.then(() => {
console.log('---------- stopServiceExtensionAbility success -----------');
})
.catch((err) => {
console.log('---------- stopServiceExtensionAbility fail, err: -----------', err);
......@@ -610,8 +610,8 @@ Stops a Service Extension ability in the same application with the account ID sp
};
var accountId = 100;
this.context.stopServiceExtensionAbilityWithAccount(want,accountId)
.then((data) => {
console.log('---------- stopServiceExtensionAbilityWithAccount success, data: -----------', data);
.then(() => {
console.log('---------- stopServiceExtensionAbilityWithAccount success -----------');
})
.catch((err) => {
console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err);
......@@ -658,8 +658,8 @@ Terminates this ability. This API uses a promise to return the result.
**Example**
```js
this.context.terminateSelf().then((data) => {
console.log('success:' + JSON.stringify(data));
this.context.terminateSelf().then(() => {
console.log('success');
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
......@@ -839,8 +839,8 @@ Disconnects a connection. This API uses a promise to return the result.
```js
var connectionNumber = 0;
this.context.disconnectAbility(connectionNumber).then((data) => {
console.log('disconnectAbility success, data: ', data);
this.context.disconnectAbility(connectionNumber).then(() => {
console.log('disconnectAbility success');
}).catch((err) => {
console.log('disconnectAbility fail, err: ', err);
});
......@@ -1020,8 +1020,8 @@ Starts an ability with the account ID specified. This API uses a promise to retu
windowMode: 0,
};
this.context.startAbilityWithAccount(want, accountId, options)
.then((data) => {
console.log('---------- startAbilityWithAccount success, data: -----------', data);
.then(() => {
console.log('---------- startAbilityWithAccount success -----------');
})
.catch((err) => {
console.log('---------- startAbilityWithAccount fail, err: -----------', err);
......@@ -1134,8 +1134,8 @@ Sets a label for this ability in the mission. This API uses a promise to return
**Example**
```js
this.context.setMissionLabel("test").then((data) => {
console.log('success:' + JSON.stringify(data));
this.context.setMissionLabel("test").then(() => {
console.log('success');
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
......@@ -1224,8 +1224,8 @@ Sets an icon for this ability in the mission. This API uses a promise to return
console.log('--------- createPixelMap fail, err: ---------', err)
});
this.context.setMissionIcon(imagePixelMap)
.then((data) => {
console.log('-------------- setMissionIcon success, data: -------------', data);
.then(() => {
console.log('-------------- setMissionIcon success -------------');
})
.catch((err) => {
console.log('-------------- setMissionIcon fail, err: -------------', err);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册