diff --git a/zh-cn/application-dev/ability/stage-ability.md b/zh-cn/application-dev/ability/stage-ability.md index 660c3016acc0849e665cc6609fa109421731446f..bdc1796d655a68f3fef1b05f0ef3675642bc1ae6 100644 --- a/zh-cn/application-dev/ability/stage-ability.md +++ b/zh-cn/application-dev/ability/stage-ability.md @@ -51,16 +51,16 @@ Ability类拥有context属性,context属性为AbilityContext类,AbilityConte **表3** AbilityContext API接口功能介绍 |接口名|描述| |:------|:------| -|void startAbility(want: Want, callback: AsyncCallback)|启动Ability。| -|void startAbility(want: Want, options: StartOptions, callback: AsyncCallback)|启动Ability。| -|void startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback)|带AccountId启动Ability。| -|void startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback)|带AccountId启动Ability。| -|void startAbilityForResult(want: Want, callback: AsyncCallback)|带返回结果启动Ability。| -|void startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback)|带返回结果启动Ability。| -|void startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback)|带返回结果及AccountId启动Ability。| -|void startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback)|带返回结果及AccountId启动Ability。| -|void terminateSelf(callback: AsyncCallback)|销毁当前的Page Ability。| -|void terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback)|带返回结果销毁当前的Page Ability。| +|void startAbility(want: Want, callback: AsyncCallback\)|启动Ability。| +|void startAbility(want: Want, options: StartOptions, callback: AsyncCallback\)|启动Ability。| +|void startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\)|带AccountId启动Ability。| +|void startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\)|带AccountId启动Ability。| +|void startAbilityForResult(want: Want, callback: AsyncCallback\)|带返回结果启动Ability。| +|void startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback\)|带返回结果启动Ability。| +|void startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback\)|带返回结果及AccountId启动Ability。| +|void startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\)|带返回结果及AccountId启动Ability。| +|void terminateSelf(callback: AsyncCallback\)|销毁当前的Page Ability。| +|void terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\)|带返回结果销毁当前的Page Ability。| ## 开发步骤 ### 创建Page Ability应用 @@ -100,7 +100,7 @@ Ability类拥有context属性,context属性为AbilityContext类,AbilityConte windowStage.loadContent("pages/index").then((data) => { console.log("MainAbility load content succeed with data: " + JSON.stringify(data)) }).catch((error) => { - console.error("MainAbility load content failed with error: "+ JSON.stringify(error)) + console.error("MainAbility load content failed with error: " + JSON.stringify(error)) }) } @@ -189,7 +189,7 @@ var want = { context.startAbility(want).then((data) => { console.log("Succeed to start remote ability with data: " + JSON.stringify(data)) }).catch((error) => { - console.error("Failed to start remote ability with error: "+ JSON.stringify(error)) + console.error("Failed to start remote ability with error: " + JSON.stringify(error)) }) ``` 从DeviceManager获取指定设备的deviceId。具体示例代码如下: @@ -225,9 +225,9 @@ module.json的修改: let context = this.context let permissions: Array = ['ohos.permission.READ_CALENDAR'] context.requestPermissionsFromUser(permissions).then((data) => { - console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) + console.log("Succeed to request permission from user with data: " + JSON.stringify(data)) }).catch((error) => { - console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) + console.log("Failed to request permission from user with error: " + JSON.stringify(error)) }) ``` 在跨设备场景下,需要向用户申请数据同步的权限。具体示例代码如下: @@ -235,9 +235,9 @@ context.requestPermissionsFromUser(permissions).then((data) => { let context = this.context let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] context.requestPermissionsFromUser(permissions).then((data) => { - console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) + console.log("Succeed to request permission from user with data: " + JSON.stringify(data)) }).catch((error) => { - console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) + console.log("Failed to request permission from user with error: " + JSON.stringify(error)) }) ```