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

!3899 【轻量级 PR】:【OpenHarmony开源贡献者计划2022】修复...

!3899 【轻量级 PR】:【OpenHarmony开源贡献者计划2022】修复 zh-cn/application-dev/ability/stage-ability.md 中的 Markdown 语法问题与代码规范
Merge pull request !3899 from Geno1024/N/A
...@@ -51,16 +51,16 @@ Ability类拥有context属性,context属性为AbilityContext类,AbilityConte ...@@ -51,16 +51,16 @@ Ability类拥有context属性,context属性为AbilityContext类,AbilityConte
**表3** AbilityContext API接口功能介绍 **表3** AbilityContext API接口功能介绍
|接口名|描述| |接口名|描述|
|:------|:------| |:------|:------|
|void startAbility(want: Want, callback: AsyncCallback<void>)|启动Ability。| |void startAbility(want: Want, callback: AsyncCallback\<void>)|启动Ability。|
|void startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>)|启动Ability。| |void startAbility(want: Want, options: StartOptions, callback: AsyncCallback\<void>)|启动Ability。|
|void startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback<void>)|带AccountId启动Ability。| |void startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>)|带AccountId启动Ability。|
|void startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback<void>)|带AccountId启动Ability。| |void startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\<void>)|带AccountId启动Ability。|
|void startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>)|带返回结果启动Ability。| |void startAbilityForResult(want: Want, callback: AsyncCallback\<AbilityResult>)|带返回结果启动Ability。|
|void startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>)|带返回结果启动Ability。| |void startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback\<AbilityResult>)|带返回结果启动Ability。|
|void startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback<AbilityResult>)|带返回结果及AccountId启动Ability。| |void startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback\<AbilityResult>)|带返回结果及AccountId启动Ability。|
|void startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback<void>)|带返回结果及AccountId启动Ability。| |void startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\<void>)|带返回结果及AccountId启动Ability。|
|void terminateSelf(callback: AsyncCallback<void>)|销毁当前的Page Ability。| |void terminateSelf(callback: AsyncCallback\<void>)|销毁当前的Page Ability。|
|void terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>)|带返回结果销毁当前的Page Ability。| |void terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\<void>)|带返回结果销毁当前的Page Ability。|
## 开发步骤 ## 开发步骤
### 创建Page Ability应用 ### 创建Page Ability应用
...@@ -100,7 +100,7 @@ Ability类拥有context属性,context属性为AbilityContext类,AbilityConte ...@@ -100,7 +100,7 @@ Ability类拥有context属性,context属性为AbilityContext类,AbilityConte
windowStage.loadContent("pages/index").then((data) => { windowStage.loadContent("pages/index").then((data) => {
console.log("MainAbility load content succeed with data: " + JSON.stringify(data)) console.log("MainAbility load content succeed with data: " + JSON.stringify(data))
}).catch((error) => { }).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 = { ...@@ -189,7 +189,7 @@ var want = {
context.startAbility(want).then((data) => { context.startAbility(want).then((data) => {
console.log("Succeed to start remote ability with data: " + JSON.stringify(data)) console.log("Succeed to start remote ability with data: " + JSON.stringify(data))
}).catch((error) => { }).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。具体示例代码如下: 从DeviceManager获取指定设备的deviceId。具体示例代码如下:
...@@ -225,9 +225,9 @@ module.json的修改: ...@@ -225,9 +225,9 @@ module.json的修改:
let context = this.context let context = this.context
let permissions: Array<string> = ['ohos.permission.READ_CALENDAR'] let permissions: Array<string> = ['ohos.permission.READ_CALENDAR']
context.requestPermissionsFromUser(permissions).then((data) => { 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) => { }).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) => { ...@@ -235,9 +235,9 @@ context.requestPermissionsFromUser(permissions).then((data) => {
let context = this.context let context = this.context
let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC'] let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']
context.requestPermissionsFromUser(permissions).then((data) => { 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) => { }).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))
}) })
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册