Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
b2011405
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b2011405
编写于
2月 21, 2023
作者:
M
mingxihua
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mingxihua@huawei.com.cn
Signed-off-by:
N
mingxihua
<
mingxihua@huawei.com
>
上级
4bef3bed
变更
82
隐藏空白更改
内联
并排
Showing
82 changed file
with
2041 addition
and
2041 deletion
+2041
-2041
zh-cn/application-dev/reference/apis/js-apis-ability-ability.md
...application-dev/reference/apis/js-apis-ability-ability.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-ability-context.md
...application-dev/reference/apis/js-apis-ability-context.md
+96
-96
zh-cn/application-dev/reference/apis/js-apis-ability-dataUriUtils.md
...cation-dev/reference/apis/js-apis-ability-dataUriUtils.md
+6
-6
zh-cn/application-dev/reference/apis/js-apis-ability-errorCode.md
...plication-dev/reference/apis/js-apis-ability-errorCode.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md
...tion-dev/reference/apis/js-apis-ability-featureAbility.md
+85
-85
zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md
...ion-dev/reference/apis/js-apis-ability-particleAbility.md
+66
-66
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md
...dev/reference/apis/js-apis-app-ability-abilityConstant.md
+8
-8
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md
...ence/apis/js-apis-app-ability-abilityDelegatorRegistry.md
+8
-8
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md
...ence/apis/js-apis-app-ability-abilityLifecycleCallback.md
+29
-29
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
...-dev/reference/apis/js-apis-app-ability-abilityManager.md
+16
-16
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityStage.md
...on-dev/reference/apis/js-apis-app-ability-abilityStage.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md
...tion-dev/reference/apis/js-apis-app-ability-appManager.md
+55
-55
zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
...ion-dev/reference/apis/js-apis-app-ability-appRecovery.md
+6
-6
zh-cn/application-dev/reference/apis/js-apis-app-ability-common.md
...lication-dev/reference/apis/js-apis-app-ability-common.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-app-ability-configuration.md
...n-dev/reference/apis/js-apis-app-ability-configuration.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md
...ference/apis/js-apis-app-ability-configurationConstant.md
+6
-6
zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
...reference/apis/js-apis-app-ability-environmentCallback.md
+6
-6
zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md
...on-dev/reference/apis/js-apis-app-ability-errorManager.md
+9
-9
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
...-dev/reference/apis/js-apis-app-ability-missionManager.md
+135
-135
zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md
...dev/reference/apis/js-apis-app-ability-quickFixManager.md
+20
-20
zh-cn/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
...rence/apis/js-apis-app-ability-serviceExtensionAbility.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-app-ability-startOptions.md
...on-dev/reference/apis/js-apis-app-ability-startOptions.md
+7
-7
zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
...ation-dev/reference/apis/js-apis-app-ability-uiAbility.md
+45
-45
zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md
...pplication-dev/reference/apis/js-apis-app-ability-want.md
+35
-35
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
...ation-dev/reference/apis/js-apis-app-ability-wantAgent.md
+219
-219
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md
...on-dev/reference/apis/js-apis-app-ability-wantConstant.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md
...on-dev/reference/apis/js-apis-app-form-formBindingData.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
...v/reference/apis/js-apis-app-form-formExtensionAbility.md
+10
-10
zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md
...plication-dev/reference/apis/js-apis-app-form-formHost.md
+55
-55
zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md
...ation-dev/reference/apis/js-apis-app-form-formProvider.md
+33
-33
zh-cn/application-dev/reference/apis/js-apis-application-ability.md
...ication-dev/reference/apis/js-apis-application-ability.md
+28
-28
zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
...ence/apis/js-apis-application-abilityDelegatorRegistry.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
...ence/apis/js-apis-application-abilityLifecycleCallback.md
+18
-18
zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md
...-dev/reference/apis/js-apis-application-abilityManager.md
+5
-5
zh-cn/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md
...apis/js-apis-application-accessibilityExtensionAbility.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-application-appManager.md
...tion-dev/reference/apis/js-apis-application-appManager.md
+11
-11
zh-cn/application-dev/reference/apis/js-apis-application-configuration.md
...n-dev/reference/apis/js-apis-application-configuration.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
...nce/apis/js-apis-application-dataShareExtensionAbility.md
+41
-41
zh-cn/application-dev/reference/apis/js-apis-application-environmentCallback.md
...reference/apis/js-apis-application-environmentCallback.md
+7
-7
zh-cn/application-dev/reference/apis/js-apis-application-errorManager.md
...on-dev/reference/apis/js-apis-application-errorManager.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-application-formBindingData.md
...dev/reference/apis/js-apis-application-formBindingData.md
+5
-5
zh-cn/application-dev/reference/apis/js-apis-application-formHost.md
...cation-dev/reference/apis/js-apis-application-formHost.md
+55
-55
zh-cn/application-dev/reference/apis/js-apis-application-formProvider.md
...on-dev/reference/apis/js-apis-application-formProvider.md
+32
-32
zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md
...-dev/reference/apis/js-apis-application-missionManager.md
+125
-125
zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
...s/js-apis-application-staticSubscriberExtensionAbility.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-application-testRunner.md
...tion-dev/reference/apis/js-apis-application-testRunner.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-application-want.md
...pplication-dev/reference/apis/js-apis-application-want.md
+36
-36
zh-cn/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md
...ev/reference/apis/js-apis-inner-ability-connectOptions.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md
...reference/apis/js-apis-inner-ability-dataAbilityHelper.md
+163
-163
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md
...reference/apis/js-apis-inner-ability-dataAbilityResult.md
+6
-6
zh-cn/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md
...rence/apis/js-apis-inner-ability-startAbilityParameter.md
+7
-7
zh-cn/application-dev/reference/apis/js-apis-inner-ability-want.md
...lication-dev/reference/apis/js-apis-inner-ability-want.md
+18
-18
zh-cn/application-dev/reference/apis/js-apis-inner-app-context.md
...plication-dev/reference/apis/js-apis-inner-app-context.md
+59
-59
zh-cn/application-dev/reference/apis/js-apis-inner-app-processInfo.md
...ation-dev/reference/apis/js-apis-inner-app-processInfo.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md
...erence/apis/js-apis-inner-application-abilityDelegator.md
+92
-92
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md
...eference/apis/js-apis-inner-application-abilityMonitor.md
+5
-5
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityRunningInfo.md
...ence/apis/js-apis-inner-application-abilityRunningInfo.md
+7
-7
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityStageMonitor.md
...nce/apis/js-apis-inner-application-abilityStageMonitor.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md
...s-apis-inner-application-accessibilityExtensionContext.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-inner-application-appStateData.md
.../reference/apis/js-apis-inner-application-appStateData.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md
...ence/apis/js-apis-inner-application-applicationContext.md
+58
-58
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md
...pis/js-apis-inner-application-applicationStateObserver.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md
...v/reference/apis/js-apis-inner-application-baseContext.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md
...n-dev/reference/apis/js-apis-inner-application-context.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueCallback.md
...erence/apis/js-apis-inner-application-continueCallback.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueDeviceInfo.md
...ence/apis/js-apis-inner-application-continueDeviceInfo.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md
...reference/apis/js-apis-inner-application-errorObserver.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md
...-dev/reference/apis/js-apis-inner-application-eventHub.md
+19
-19
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md
...erence/apis/js-apis-inner-application-extensionContext.md
+16
-16
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md
...ce/apis/js-apis-inner-application-extensionRunningInfo.md
+8
-8
zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md
...ce/apis/js-apis-inner-application-formExtensionContext.md
+21
-21
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionCallbacks.md
...erence/apis/js-apis-inner-application-missionCallbacks.md
+6
-6
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionDeviceInfo.md
...rence/apis/js-apis-inner-application-missionDeviceInfo.md
+6
-6
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionInfo.md
...v/reference/apis/js-apis-inner-application-missionInfo.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md
...ference/apis/js-apis-inner-application-missionListener.md
+7
-7
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionParameter.md
...erence/apis/js-apis-inner-application-missionParameter.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md
...ference/apis/js-apis-inner-application-missionSnapshot.md
+9
-9
zh-cn/application-dev/reference/apis/js-apis-inner-application-processInformation.md
...ence/apis/js-apis-inner-application-processInformation.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md
...apis/js-apis-inner-application-serviceExtensionContext.md
+56
-56
zh-cn/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md
...eference/apis/js-apis-inner-application-shellCmdResult.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
...erence/apis/js-apis-inner-application-uiAbilityContext.md
+85
-85
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md
.../apis/js-apis-inner-application-windowExtensionContext.md
+5
-5
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-ability-ability.md
浏览文件 @
b2011405
...
...
@@ -10,7 +10,7 @@ Ability模块将二级模块API组织在一起方便开发者进行导出。
## 导入模块
```
ts
import
ability
from
'
@ohos.ability.ability
'
import
ability
from
'
@ohos.ability.ability
'
;
```
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
...
...
zh-cn/application-dev/reference/apis/js-apis-ability-context.md
浏览文件 @
b2011405
...
...
@@ -65,8 +65,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void;
```
ts
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
try
{
...
...
@@ -120,9 +120,9 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
options
=
{
windowMode
:
0
...
...
@@ -183,8 +183,8 @@ startAbility(want: Want, options?: StartOptions): Promise<void>;
```
ts
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
let
options
=
{
windowMode
:
0
,
...
...
@@ -243,9 +243,9 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>):
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -257,8 +257,8 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>):
return
;
}
// 执行正常业务
console
.
log
(
"
startAbilityForResult succeed, result.resultCode =
"
+
result
.
resultCode
)
console
.
log
(
'
startAbilityForResult succeed, result.resultCode =
'
+
result
.
resultCode
)
;
});
}
catch
(
paramError
)
{
// 处理入参错误异常
...
...
@@ -302,9 +302,9 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
options
=
{
windowMode
:
0
,
...
...
@@ -319,8 +319,8 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
return
;
}
// 执行正常业务
console
.
log
(
"
startAbilityForResult succeed, result.resultCode =
"
+
result
.
resultCode
)
console
.
log
(
'
startAbilityForResult succeed, result.resultCode =
'
+
result
.
resultCode
)
;
});
}
catch
(
paramError
)
{
// 处理入参错误异常
...
...
@@ -371,8 +371,8 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes
```
ts
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
let
options
=
{
windowMode
:
0
,
...
...
@@ -382,7 +382,7 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes
this
.
context
.
startAbilityForResult
(
want
,
options
)
.
then
((
result
)
=>
{
// 执行正常业务
console
.
log
(
"
startAbilityForResult succeed, result.resultCode =
"
+
result
.
resultCode
);
console
.
log
(
'
startAbilityForResult succeed, result.resultCode =
'
+
result
.
resultCode
);
})
.
catch
((
error
)
=>
{
// 处理业务逻辑错误
...
...
@@ -432,9 +432,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -447,8 +447,8 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC
return
;
}
// 执行正常业务
console
.
log
(
"
startAbilityForResultWithAccount succeed, result.resultCode =
"
+
result
.
resultCode
)
console
.
log
(
'
startAbilityForResultWithAccount succeed, result.resultCode =
'
+
result
.
resultCode
)
;
});
}
catch
(
paramError
)
{
// 处理入参错误异常
...
...
@@ -495,9 +495,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -513,8 +513,8 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
return
;
}
// 执行正常业务
console
.
log
(
"
startAbilityForResultWithAccount succeed, result.resultCode =
"
+
result
.
resultCode
)
console
.
log
(
'
startAbilityForResultWithAccount succeed, result.resultCode =
'
+
result
.
resultCode
)
;
});
}
catch
(
paramError
)
{
// 处理入参错误异常
...
...
@@ -566,9 +566,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -579,8 +579,8 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
this
.
context
.
startAbilityForResultWithAccount
(
want
,
accountId
,
options
)
.
then
((
result
)
=>
{
// 执行正常业务
console
.
log
(
"
startAbilityForResultWithAccount succeed, result.resultCode =
"
+
result
.
resultCode
)
console
.
log
(
'
startAbilityForResultWithAccount succeed, result.resultCode =
'
+
result
.
resultCode
)
;
})
.
catch
((
error
)
=>
{
// 处理业务逻辑错误
...
...
@@ -621,9 +621,9 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -671,9 +671,9 @@ startServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -725,9 +725,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -779,9 +779,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -830,9 +830,9 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -880,9 +880,9 @@ stopServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -934,9 +934,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -988,9 +988,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -1110,15 +1110,15 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi
```
ts
let
want
=
{
bundleName
:
"
com.extreme.myapplication
"
,
abilityName
:
"
SecondAbility
"
}
bundleName
:
'
com.extreme.myapplication
'
,
abilityName
:
'
SecondAbility
'
}
;
let
resultCode
=
100
;
// 返回给接口调用方AbilityResult信息
let
abilityResult
=
{
want
,
resultCode
}
}
;
try
{
this
.
context
.
terminateSelfWithResult
(
abilityResult
,
(
error
)
=>
{
...
...
@@ -1172,15 +1172,15 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>;
```
ts
let
want
=
{
bundleName
:
"
com.extreme.myapplication
"
,
abilityName
:
"
SecondAbility
"
}
bundleName
:
'
com.extreme.myapplication
'
,
abilityName
:
'
SecondAbility
'
}
;
let
resultCode
=
100
;
// 返回给接口调用方AbilityResult信息
let
abilityResult
=
{
want
,
resultCode
}
}
;
try
{
this
.
context
.
terminateSelfWithResult
(
abilityResult
)
...
...
@@ -1234,9 +1234,9 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
...
...
@@ -1292,9 +1292,9 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -1446,10 +1446,10 @@ startAbilityByCall(want: Want): Promise<Caller>;
// 后台启动Ability,不配置parameters
let
wantBackground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
};
try
{
...
...
@@ -1475,14 +1475,14 @@ startAbilityByCall(want: Want): Promise<Caller>;
```
ts
let
caller
=
undefined
;
// 前台启动Ability,将parameters中的
"ohos.aafwk.param.callAbilityToForeground"
配置为true
// 前台启动Ability,将parameters中的
'ohos.aafwk.param.callAbilityToForeground'
配置为true
let
wantForeground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
,
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
,
parameters
:
{
"
ohos.aafwk.param.callAbilityToForeground
"
:
true
'
ohos.aafwk.param.callAbilityToForeground
'
:
true
}
};
...
...
@@ -1540,9 +1540,9 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -1602,9 +1602,9 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -1666,9 +1666,9 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -1711,7 +1711,7 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void;
**示例:**
```
ts
this
.
context
.
setMissionLabel
(
"
test
"
,(
result
)
=>
{
this
.
context
.
setMissionLabel
(
'
test
'
,(
result
)
=>
{
console
.
log
(
'
setMissionLabel result:
'
+
JSON
.
stringify
(
result
));
});
```
...
...
@@ -1740,7 +1740,7 @@ setMissionLabel(label: string): Promise<void>;
**示例:**
```
ts
this
.
context
.
setMissionLabel
(
"
test
"
).
then
(()
=>
{
this
.
context
.
setMissionLabel
(
'
test
'
).
then
(()
=>
{
console
.
log
(
'
success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
failed:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -1780,7 +1780,7 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void;
imagePixelMap
=
data
;
})
.
catch
((
err
)
=>
{
console
.
log
(
'
--------- createPixelMap fail, err: ---------
'
,
err
)
console
.
log
(
'
--------- createPixelMap fail, err: ---------
'
,
err
)
;
});
this
.
context
.
setMissionIcon
(
imagePixelMap
,
(
err
)
=>
{
console
.
log
(
'
---------- setMissionIcon fail, err: -----------
'
,
err
);
...
...
@@ -1827,7 +1827,7 @@ setMissionIcon(icon: image.PixelMap): Promise\<void>;
imagePixelMap
=
data
;
})
.
catch
((
err
)
=>
{
console
.
log
(
'
--------- createPixelMap fail, err: ---------
'
,
err
)
console
.
log
(
'
--------- createPixelMap fail, err: ---------
'
,
err
)
;
});
this
.
context
.
setMissionIcon
(
imagePixelMap
)
.
then
(()
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-ability-dataUriUtils.md
浏览文件 @
b2011405
...
...
@@ -35,7 +35,7 @@ getId(uri: string): number
**示例:**
```
ts
let
id
=
dataUriUtils
.
getId
(
"
com.example.dataUriUtils/1221
"
);
let
id
=
dataUriUtils
.
getId
(
'
com.example.dataUriUtils/1221
'
);
```
...
...
@@ -66,9 +66,9 @@ attachId(uri: string, id: number): string
```
ts
let
id
=
1122
;
let
uri
=
dataUriUtils
.
attachId
(
"
com.example.dataUriUtils
"
,
'
com.example.dataUriUtils
'
,
id
,
)
)
;
```
...
...
@@ -96,7 +96,7 @@ deleteId(uri: string): string
**示例:**
```
ts
let
uri
=
dataUriUtils
.
deleteId
(
"
com.example.dataUriUtils/1221
"
)
let
uri
=
dataUriUtils
.
deleteId
(
'
com.example.dataUriUtils/1221
'
);
```
...
...
@@ -127,8 +127,8 @@ updateId(uri: string, id: number): string
```
ts
let
id
=
1122
;
let
uri
=
dataUriUtils
.
updateId
(
"
com.example.dataUriUtils/1221
"
,
'
com.example.dataUriUtils/1221
'
,
id
)
)
;
```
zh-cn/application-dev/reference/apis/js-apis-ability-errorCode.md
浏览文件 @
b2011405
...
...
@@ -9,7 +9,7 @@ ErrorCode定义启动Ability时返回的错误码,包括无效的参数、权
## 导入模块
```
ts
import
errorCode
from
'
@ohos.ability.errorCode
'
import
errorCode
from
'
@ohos.ability.errorCode
'
;
```
## ErrorCode
...
...
zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md
浏览文件 @
b2011405
...
...
@@ -46,19 +46,19 @@ featureAbility.startAbility(
{
want
:
{
action
:
""
,
entities
:
[
""
],
type
:
""
,
action
:
''
,
entities
:
[
''
],
type
:
''
,
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
/* FA模型中abilityName由package + Ability name组成 */
abilityName
:
"
com.example.myapplication.secondAbility
"
,
uri
:
""
abilityName
:
'
com.example.myapplication.secondAbility
'
,
uri
:
''
},
},
(
err
,
data
)
=>
{
console
.
info
(
"
startAbility err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
startAbility err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
}
);
```
...
...
@@ -99,19 +99,19 @@ featureAbility.startAbility(
{
want
:
{
action
:
"
action.system.home
"
,
entities
:
[
"
entity.system.home
"
],
type
:
"
MIMETYPE
"
,
action
:
'
action.system.home
'
,
entities
:
[
'
entity.system.home
'
],
type
:
'
MIMETYPE
'
,
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
/* FA模型中abilityName由package + Ability name组成 */
abilityName
:
"
com.example.myapplication.secondAbility
"
,
uri
:
""
abilityName
:
'
com.example.myapplication.secondAbility
'
,
uri
:
''
},
}
).
then
((
data
)
=>
{
console
.
info
(
"
startAbility data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
startAbility data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -140,7 +140,7 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
```
...
...
@@ -176,19 +176,19 @@ featureAbility.startAbilityForResult(
{
want
:
{
action
:
"
action.system.home
"
,
entities
:
[
"
entity.system.home
"
],
type
:
"
MIMETYPE
"
,
action
:
'
action.system.home
'
,
entities
:
[
'
entity.system.home
'
],
type
:
'
MIMETYPE
'
,
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
/* FA模型中abilityName由package + Ability name组成 */
abilityName
:
"
com.example.myapplication.secondAbility
"
,
uri
:
""
abilityName
:
'
com.example.myapplication.secondAbility
'
,
uri
:
''
},
},
(
err
,
data
)
=>
{
console
.
info
(
"
startAbilityForResult err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
startAbilityForResult err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
}
);
```
...
...
@@ -230,30 +230,30 @@ featureAbility.startAbilityForResult(
{
want
:
{
action
:
"
action.system.home
"
,
entities
:
[
"
entity.system.home
"
],
type
:
"
MIMETYPE
"
,
action
:
'
action.system.home
'
,
entities
:
[
'
entity.system.home
'
],
type
:
'
MIMETYPE
'
,
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
/* FA模型中abilityName由package + Ability name组成 */
abilityName
:
"
com.example.myapplication.secondAbility
"
,
uri
:
""
,
abilityName
:
'
com.example.myapplication.secondAbility
'
,
uri
:
''
,
parameters
:
{
mykey0
:
1111
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
xxxxxxxxxxxxxxxxxxxxxx
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
xxxxxxxxxxxxxxxxxxxxxx
'
,
mykey4
:
[
1
,
15
],
mykey5
:
[
false
,
true
,
false
],
mykey6
:
[
"
aaaaaa
"
,
"
bbbbb
"
,
"
ccccccccccc
"
],
mykey6
:
[
'
aaaaaa
'
,
'
bbbbb
'
,
'
ccccccccccc
'
],
mykey7
:
true
,
},
},
},
).
then
((
data
)
=>
{
console
.
info
(
"
startAbilityForResult data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
startAbilityForResult data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -282,29 +282,29 @@ featureAbility.terminateSelfWithResult(
resultCode
:
1
,
want
:
{
action
:
"
action.system.home
"
,
entities
:
[
"
entity.system.home
"
],
type
:
"
MIMETYPE
"
,
action
:
'
action.system.home
'
,
entities
:
[
'
entity.system.home
'
],
type
:
'
MIMETYPE
'
,
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
/* FA模型中abilityName由package + Ability name组成 */
abilityName
:
"
com.example.myapplication.secondAbility
"
,
uri
:
""
,
abilityName
:
'
com.example.myapplication.secondAbility
'
,
uri
:
''
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
1
,
15
],
mykey5
:
[
false
,
true
,
false
],
mykey6
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey6
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey7
:
true
,
}
},
},
(
err
)
=>
{
console
.
info
(
"
err:
"
+
JSON
.
stringify
(
err
))
console
.
error
(
'
err:
'
+
JSON
.
stringify
(
err
));
}
);
```
...
...
@@ -339,29 +339,29 @@ featureAbility.terminateSelfWithResult(
resultCode
:
1
,
want
:
{
action
:
"
action.system.home
"
,
entities
:
[
"
entity.system.home
"
],
type
:
"
MIMETYPE
"
,
action
:
'
action.system.home
'
,
entities
:
[
'
entity.system.home
'
],
type
:
'
MIMETYPE
'
,
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
/* FA模型中abilityName由package + Ability name组成 */
abilityName
:
"
com.example.myapplication.secondAbility
"
,
uri
:
""
,
abilityName
:
'
com.example.myapplication.secondAbility
'
,
uri
:
''
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
1
,
15
],
mykey5
:
[
false
,
true
,
false
],
mykey6
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey6
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey7
:
true
,
}
},
}
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>terminateSelfWithResult=======================>
"
);
console
.
info
(
'
==========================>terminateSelfWithResult=======================>
'
);
});
```
...
...
@@ -384,7 +384,7 @@ 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
));
console
.
info
(
'
hasWindowFocus err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -407,7 +407,7 @@ hasWindowFocus(): Promise\<boolean>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
hasWindowFocus
().
then
((
data
)
=>
{
console
.
info
(
"
hasWindowFocus data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
hasWindowFocus data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -430,7 +430,7 @@ 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
));
console
.
info
(
'
getWant err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -453,7 +453,7 @@ getWant(): Promise\<Want>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
getWant
().
then
((
data
)
=>
{
console
.
info
(
"
getWant data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getWant data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -475,9 +475,9 @@ getContext(): Context
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
()
let
context
=
featureAbility
.
getContext
()
;
context
.
getBundleName
((
err
,
data
)
=>
{
console
.
info
(
"
getBundleName err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getBundleName err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -501,7 +501,7 @@ terminateSelf(callback: AsyncCallback\<void>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
terminateSelf
(
(
err
)
=>
{
console
.
info
(
"
err:
"
+
JSON
.
stringify
(
err
))
console
.
error
(
'
err:
'
+
JSON
.
stringify
(
err
));
}
)
```
...
...
@@ -525,7 +525,7 @@ terminateSelf(): Promise\<void>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
terminateSelf
().
then
((
data
)
=>
{
console
.
info
(
"
==========================>terminateSelf=======================>
"
);
console
.
info
(
'
==========================>terminateSelf=======================>
'
);
});
```
...
...
@@ -566,9 +566,9 @@ function onFailedCallback(code){
}
let
connectId
=
featureAbility
.
connectAbility
(
{
deviceId
:
""
,
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
com.ix.ServiceAbility.ServiceAbilityA
"
,
deviceId
:
''
,
bundleName
:
'
com.ix.ServiceAbility
'
,
abilityName
:
'
com.ix.ServiceAbility.ServiceAbilityA
'
,
},
{
onConnect
:
onConnectCallback
,
...
...
@@ -602,15 +602,15 @@ function onConnectCallback(element, remote){
console
.
log
(
'
ConnectAbility onConnect remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
));
}
function
onDisconnectCallback
(
element
){
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
;
}
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
;
}
let
connectId
=
featureAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
com.ix.ServiceAbility.ServiceAbilityA
"
,
bundleName
:
'
com.ix.ServiceAbility
'
,
abilityName
:
'
com.ix.ServiceAbility.ServiceAbilityA
'
,
},
{
onConnect
:
onConnectCallback
,
...
...
@@ -620,8 +620,8 @@ let connectId = featureAbility.connectAbility(
);
featureAbility
.
disconnectAbility
(
connectId
,
(
err
)
=>
{
console
.
log
(
"
featureAbilityTest disconnectAbility err====>
"
+
(
"
json err=
"
)
+
JSON
.
stringify
(
err
));
console
.
error
(
'
featureAbilityTest disconnectAbility err====>
'
+
(
'
json err=
'
)
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -654,15 +654,15 @@ function onConnectCallback(element, remote){
console
.
log
(
'
ConnectAbility onConnect remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
));
}
function
onDisconnectCallback
(
element
){
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
;
}
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
;
}
let
connectId
=
featureAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
com.ix.ServiceAbility.ServiceAbilityA
"
,
bundleName
:
'
com.ix.ServiceAbility
'
,
abilityName
:
'
com.ix.ServiceAbility.ServiceAbilityA
'
,
},
{
onConnect
:
onConnectCallback
,
...
...
@@ -674,7 +674,7 @@ let connectId = featureAbility.connectAbility(
featureAbility
.
disconnectAbility
(
connectId
).
then
((
data
)
=>
{
console
.
log
(
'
data :
'
+
data
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
featureAbilityTest result errCode :
'
+
error
.
code
);
console
.
error
(
'
featureAbilityTest result errCode :
'
+
error
.
code
);
});
```
...
...
@@ -697,7 +697,7 @@ getWindow(callback: AsyncCallback\<window.Window>): void
```
ts
featureAbility
.
getWindow
((
err
,
data
)
=>
{
console
.
info
(
"
getWindow err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
typeof
(
data
));
console
.
info
(
'
getWindow err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
typeof
(
data
));
});
```
...
...
@@ -719,7 +719,7 @@ getWindow(): Promise\<window.Window>;
```
ts
featureAbility
.
getWindow
().
then
((
data
)
=>
{
console
.
info
(
"
getWindow data:
"
+
typeof
(
data
));
console
.
info
(
'
getWindow data:
'
+
typeof
(
data
));
});
```
...
...
@@ -760,9 +760,9 @@ featureAbility.AbilityStartSetting.BOUNDS_KEY
| 名称 | 值 | 说明 |
| ---------------------------- | --------------- | ---------------------------------------- |
| BOUNDS_KEY
<sup>
7+
</sup>
|
"abilityBounds"
| 窗口显示大小属性的参数名。 |
| WINDOW_MODE_KEY
<sup>
7+
</sup>
|
"windowMode"
| 窗口显示模式属性的参数名。|
| DISPLAY_ID_KEY
<sup>
7+
</sup>
|
"displayId"
| 窗口显示设备ID属性的参数名。 |
| BOUNDS_KEY
<sup>
7+
</sup>
|
'abilityBounds'
| 窗口显示大小属性的参数名。 |
| WINDOW_MODE_KEY
<sup>
7+
</sup>
|
'windowMode'
| 窗口显示模式属性的参数名。|
| DISPLAY_ID_KEY
<sup>
7+
</sup>
|
'displayId'
| 窗口显示设备ID属性的参数名。 |
## ErrorCode
...
...
zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md
浏览文件 @
b2011405
...
...
@@ -14,7 +14,7 @@ particleAbility模块用来对Data和Service类型的Ability进行操作。
## 导入模块
```
ts
import
particleAbility
from
'
@ohos.ability.particleAbility
'
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
```
## particleAbility.startAbility
...
...
@@ -40,27 +40,27 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>):
**示例:**
```
ts
import
particleAbility
from
'
@ohos.ability.particleAbility
'
import
wantConstant
from
'
@ohos.ability.wantConstant
'
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
import
wantConstant
from
'
@ohos.ability.wantConstant
'
;
particleAbility
.
startAbility
(
{
want
:
{
action
:
"
action.system.home
"
,
entities
:
[
"
entity.system.home
"
],
type
:
"
MIMETYPE
"
,
action
:
'
action.system.home
'
,
entities
:
[
'
entity.system.home
'
],
type
:
'
MIMETYPE
'
,
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.Data
"
,
abilityName
:
"
com.example.Data.MainAbility
"
,
uri
:
""
deviceId
:
''
,
bundleName
:
'
com.example.Data
'
,
abilityName
:
'
com.example.Data.MainAbility
'
,
uri
:
''
},
},
(
error
,
result
)
=>
{
console
.
log
(
'
particleAbility startAbility errCode:
'
+
error
+
'
result:
'
+
result
)
console
.
log
(
'
particleAbility startAbility errCode:
'
+
error
+
'
result:
'
+
result
)
;
},
)
)
;
```
## particleAbility.startAbility
...
...
@@ -91,25 +91,25 @@ startAbility(parameter: StartAbilityParameter): Promise\<void>;
**示例:**
```
ts
import
particleAbility
from
'
@ohos.ability.particleAbility
'
import
wantConstant
from
'
@ohos.ability.wantConstant
'
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
import
wantConstant
from
'
@ohos.ability.wantConstant
'
;
particleAbility
.
startAbility
(
{
want
:
{
action
:
"
action.system.home
"
,
entities
:
[
"
entity.system.home
"
],
type
:
"
MIMETYPE
"
,
action
:
'
action.system.home
'
,
entities
:
[
'
entity.system.home
'
],
type
:
'
MIMETYPE
'
,
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.Data
"
,
abilityName
:
"
com.example. Data.MainAbility
"
,
uri
:
""
deviceId
:
''
,
bundleName
:
'
com.example.Data
'
,
abilityName
:
'
com.example. Data.MainAbility
'
,
uri
:
''
},
},
).
then
((
data
)
=>
{
console
.
info
(
"
particleAbility startAbility
"
);
console
.
info
(
'
particleAbility startAbility
'
);
});
```
...
...
@@ -130,13 +130,13 @@ terminateSelf(callback: AsyncCallback\<void>): void
**示例:**
```
ts
import
particleAbility
from
'
@ohos.ability.particleAbility
'
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
particleAbility
.
terminateSelf
(
(
error
,
result
)
=>
{
console
.
log
(
'
particleAbility terminateSelf errCode:
'
+
error
+
'
result:
'
+
result
)
console
.
log
(
'
particleAbility terminateSelf errCode:
'
+
error
+
'
result:
'
+
result
)
;
}
)
)
;
```
## particleAbility.terminateSelf
...
...
@@ -156,10 +156,10 @@ terminateSelf(): Promise\<void>
**示例:**
```
ts
import
particleAbility
from
'
@ohos.ability.particleAbility
'
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
particleAbility
.
terminateSelf
().
then
((
data
)
=>
{
console
.
info
(
"
particleAbility terminateSelf
"
);
console
.
info
(
'
particleAbility terminateSelf
'
);
});
```
...
...
@@ -188,10 +188,10 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper
**示例:**
```
ts
import
particleAbility
from
'
@ohos.ability.particleAbility
'
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
let
uri
=
""
;
particleAbility
.
acquireDataAbilityHelper
(
uri
)
let
uri
=
''
;
particleAbility
.
acquireDataAbilityHelper
(
uri
)
;
```
...
...
@@ -222,17 +222,17 @@ import wantAgent from '@ohos.wantAgent';
function
callback
(
err
,
data
)
{
if
(
err
)
{
console
.
error
(
"
Operation failed cause:
"
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed cause:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
Operation succeeded
"
);
console
.
info
(
'
Operation succeeded
'
);
}
}
let
wantAgentInfo
=
{
wants
:
[
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
com.example.myapplication.MainAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
com.example.myapplication.MainAbility
'
}
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
...
...
@@ -242,8 +242,8 @@ let wantAgentInfo = {
wantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
wantAgentObj
)
=>
{
let
basicContent
=
{
title
:
"
title
"
,
text
:
"
text
"
title
:
'
title
'
,
text
:
'
text
'
};
let
notificationContent
=
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
...
...
@@ -292,8 +292,8 @@ import wantAgent from '@ohos.wantAgent';
let
wantAgentInfo
=
{
wants
:
[
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
com.example.myapplication.MainAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
com.example.myapplication.MainAbility
'
}
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
...
...
@@ -303,8 +303,8 @@ let wantAgentInfo = {
wantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
wantAgentObj
)
=>
{
let
basicContent
=
{
title
:
"
title
"
,
text
:
"
text
"
title
:
'
title
'
,
text
:
'
text
'
};
let
notificationContent
=
{
contentType
:
notification
.
ContentType
.
NOTIFICATION_CONTENT_BASIC_TEXT
,
...
...
@@ -316,9 +316,9 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
};
let
id
=
1
;
particleAbility
.
startBackgroundRunning
(
id
,
request
).
then
(()
=>
{
console
.
info
(
"
Operation succeeded
"
);
console
.
info
(
'
Operation succeeded
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
"
Operation failed cause:
"
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed cause:
'
+
JSON
.
stringify
(
err
));
});
});
...
...
@@ -345,9 +345,9 @@ import particleAbility from '@ohos.ability.particleAbility';
function
callback
(
err
,
data
)
{
if
(
err
)
{
console
.
error
(
"
Operation failed cause:
"
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed cause:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
info
(
"
Operation succeeded
"
);
console
.
info
(
'
Operation succeeded
'
);
}
}
...
...
@@ -375,9 +375,9 @@ cancelBackgroundRunning(): Promise<void>;
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
particleAbility
.
cancelBackgroundRunning
().
then
(()
=>
{
console
.
info
(
"
Operation succeeded
"
);
console
.
info
(
'
Operation succeeded
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
"
Operation failed cause:
"
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Operation failed cause:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -401,25 +401,25 @@ connectAbility(request: Want, options:ConnectOptions): number
**示例**
:
```
ts
import
particleAbility
from
'
@ohos.ability.particleAbility
'
import
rpc
from
'
@ohos.rpc
'
import
particleAbility
from
'
@ohos.ability.particleAbility
'
;
import
rpc
from
'
@ohos.rpc
'
;
function
onConnectCallback
(
element
,
remote
)
{
console
.
log
(
'
ConnectAbility onConnect remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
));
}
function
onDisconnectCallback
(
element
)
{
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
;
}
function
onFailedCallback
(
code
)
{
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
;
}
let
connId
=
particleAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
bundleName
:
'
com.ix.ServiceAbility
'
,
abilityName
:
'
ServiceAbilityA
'
,
},
{
onConnect
:
onConnectCallback
,
...
...
@@ -429,9 +429,9 @@ let connId = particleAbility.connectAbility(
);
particleAbility
.
disconnectAbility
(
connId
).
then
((
data
)
=>
{
console
.
log
(
"
data:
"
+
data
);
console
.
log
(
'
data:
'
+
data
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
particleAbilityTest result errCode :
'
+
error
.
code
)
console
.
log
(
'
particleAbilityTest result errCode :
'
+
error
.
code
)
;
});
```
...
...
@@ -460,17 +460,17 @@ function onConnectCallback(element, remote) {
}
function
onDisconnectCallback
(
element
)
{
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
;
}
function
onFailedCallback
(
code
)
{
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
;
}
let
connId
=
particleAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
bundleName
:
'
com.ix.ServiceAbility
'
,
abilityName
:
'
ServiceAbilityA
'
,
},
{
onConnect
:
onConnectCallback
,
...
...
@@ -480,8 +480,8 @@ let connId = particleAbility.connectAbility(
);
particleAbility
.
disconnectAbility
(
connId
,
(
err
)
=>
{
console
.
log
(
"
particleAbilityTest disconnectAbility err====>
"
+
(
"
json err=
"
)
+
JSON
.
stringify
(
err
));
console
.
log
(
'
particleAbilityTest disconnectAbility err====>
'
+
(
'
json err=
'
)
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -511,17 +511,17 @@ function onConnectCallback(element, remote) {
}
function
onDisconnectCallback
(
element
)
{
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
console
.
log
(
'
ConnectAbility onDisconnect element.deviceId :
'
+
element
.
deviceId
)
;
}
function
onFailedCallback
(
code
)
{
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
;
}
let
connId
=
particleAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
bundleName
:
'
com.ix.ServiceAbility
'
,
abilityName
:
'
ServiceAbilityA
'
,
},
{
onConnect
:
onConnectCallback
,
...
...
@@ -531,9 +531,9 @@ let connId = particleAbility.connectAbility(
);
particleAbility
.
disconnectAbility
(
connId
).
then
((
data
)
=>
{
console
.
log
(
"
data:
"
+
data
);
console
.
log
(
'
data:
'
+
data
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
particleAbilityTest result errCode :
'
+
error
.
code
)
console
.
log
(
'
particleAbilityTest result errCode :
'
+
error
.
code
)
;
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityConstant.md
浏览文件 @
b2011405
...
...
@@ -48,7 +48,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class
MyAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
if
(
launchParam
.
launchReason
===
AbilityConstant
.
LaunchReason
.
START_ABILITY
)
{
console
.
log
(
"
The ability has been started by the way of startAbility.
"
);
console
.
log
(
'
The ability has been started by the way of startAbility.
'
);
}
}
}
...
...
@@ -74,7 +74,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class
MyAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
if
(
launchParam
.
lastExitReason
===
AbilityConstant
.
LastExitReason
.
ABILITY_NOT_RESPONDING
)
{
console
.
log
(
"
The ability has exit last because the ability was not responding.
"
);
console
.
log
(
'
The ability has exit last because the ability was not responding.
'
);
}
}
}
...
...
@@ -124,8 +124,8 @@ class MyAbility extends UIAbility {
```
ts
let
want
=
{
bundleName
:
"
com.test.example
"
,
abilityName
:
"
MainAbility
"
bundleName
:
'
com.test.example
'
,
abilityName
:
'
MainAbility
'
};
let
option
=
{
windowMode
:
AbilityConstant
.
WindowMode
.
WINDOW_MODE_FULLSCREEN
...
...
@@ -133,9 +133,9 @@ let option = {
// 确保从上下文获取到context
this
.
context
.
startAbility
(
want
,
option
).
then
(()
=
{
console
.
log
(
"
Succeed to start ability.
"
);
console
.
log
(
'
Succeed to start ability.
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
"
Failed to start ability with error:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
Failed to start ability with error:
'
+
JSON
.
stringify
(
error
));
});
```
...
...
@@ -159,7 +159,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class
MyAbility
extends
UIAbility
{
onMemoryLevel
(
level
)
{
if
(
level
===
AbilityConstant
.
MemoryLevel
.
MEMORY_LEVEL_CRITICAL
)
{
console
.
log
(
"
The memory of device is critical, please release some memory.
"
);
console
.
log
(
'
The memory of device is critical, please release some memory.
'
);
}
}
}
...
...
@@ -211,7 +211,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class
MyAbility
extends
UIAbility
{
onSaveState
(
reason
,
wantParam
)
{
if
(
reason
===
AbilityConstant
.
StateType
.
CONTINUATION
)
{
console
.
log
(
"
Save the ability data when the ability continuation.
"
);
console
.
log
(
'
Save the ability data when the ability continuation.
'
);
}
return
AbilityConstant
.
OnSaveResult
.
ALL_AGREE
;
}
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityDelegatorRegistry.md
浏览文件 @
b2011405
...
...
@@ -49,14 +49,14 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry
let
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
let
want
=
{
bundleName
:
"
com.ohos.example
"
,
abilityName
:
"
MainAbility
"
bundleName
:
'
com.ohos.example
'
,
abilityName
:
'
MainAbility
'
};
abilityDelegator
.
startAbility
(
want
,
(
err
)
=>
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
Success start ability.
"
);
console
.
log
(
'
Success start ability.
'
);
}
else
{
console
.
log
(
"
Failed start ability, error:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
Failed start ability, error:
'
+
JSON
.
stringify
(
err
));
}
})
```
...
...
@@ -81,8 +81,8 @@ getArguments(): AbilityDelegatorArgs
import
AbilityDelegatorRegistry
from
'
@ohos.app.ability.abilityDelegatorRegistry
'
;
let
args
=
AbilityDelegatorRegistry
.
getArguments
();
console
.
info
(
"
getArguments bundleName:
"
+
args
.
bundleName
);
console
.
info
(
"
getArguments parameters:
"
+
JSON
.
stringify
(
args
.
parameters
));
console
.
info
(
"
getArguments testCaseNames:
"
+
args
.
testCaseNames
);
console
.
info
(
"
getArguments testRunnerClassName:
"
+
args
.
testRunnerClassName
);
console
.
info
(
'
getArguments bundleName:
'
+
args
.
bundleName
);
console
.
info
(
'
getArguments parameters:
'
+
JSON
.
stringify
(
args
.
parameters
));
console
.
info
(
'
getArguments testCaseNames:
'
+
args
.
testCaseNames
);
console
.
info
(
'
getArguments testRunnerClassName:
'
+
args
.
testRunnerClassName
);
```
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md
浏览文件 @
b2011405
...
...
@@ -11,7 +11,7 @@ AbilityLifecycleCallback模块提供应用上下文[ApplicationContext](js-apis-
## 导入模块
```
ts
import
AbilityLifecycleCallback
from
"
@ohos.app.ability.AbilityLifecycleCallback
"
;
import
AbilityLifecycleCallback
from
'
@ohos.app.ability.AbilityLifecycleCallback
'
;
```
...
...
@@ -33,7 +33,7 @@ onAbilityCreate(ability: UIAbility): void;
```
ts
let
abilityLifecycleCallback
=
{
onAbilityCreate
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityCreate.
"
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityCreate.
'
);
}
};
```
...
...
@@ -57,7 +57,7 @@ onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void;
```
ts
let
abilityLifecycleCallback
=
{
onWindowStageCreate
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageCreate.
"
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageCreate.
'
);
}
};
```
...
...
@@ -81,7 +81,7 @@ onWindowStageActive(ability: UIAbility, windowStage: window.WindowStage): void;
```
ts
let
abilityLifecycleCallback
=
{
onWindowStageActive
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageActive.
"
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageActive.
'
);
}
};
```
...
...
@@ -105,7 +105,7 @@ onWindowStageInactive(ability: UIAbility, windowStage: window.WindowStage): void
```
ts
let
abilityLifecycleCallback
=
{
onWindowStageInactive
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageInactive.
"
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageInactive.
'
);
}
};
```
...
...
@@ -129,7 +129,7 @@ onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void;
```
ts
let
abilityLifecycleCallback
=
{
onWindowStageDestroy
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageDestroy.
"
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageDestroy.
'
);
}
};
```
...
...
@@ -152,7 +152,7 @@ onAbilityDestroy(ability: UIAbility): void;
```
ts
let
abilityLifecycleCallback
=
{
onAbilityDestroy
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityDestroy.
"
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityDestroy.
'
);
}
};
```
...
...
@@ -175,7 +175,7 @@ onAbilityForeground(ability: UIAbility): void;
```
ts
let
abilityLifecycleCallback
=
{
onAbilityForeground
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityForeground.
"
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityForeground.
'
);
}
};
```
...
...
@@ -198,7 +198,7 @@ onAbilityBackground(ability: UIAbility): void;
```
ts
let
abilityLifecycleCallback
=
{
onAbilityBackground
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityBackground.
"
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityBackground.
'
);
}
};
```
...
...
@@ -221,7 +221,7 @@ onAbilityContinue(ability: UIAbility): void;
```
ts
let
abilityLifecycleCallback
=
{
onAbilityContinue
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityContinue.
"
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityContinue.
'
);
}
};
```
...
...
@@ -232,52 +232,52 @@ let abilityLifecycleCallback = {
MyFirstAbility.ts
```
ts
import
AbilityLifecycleCallback
from
"
@ohos.app.ability.AbilityLifecycleCallback
"
;
import
AbilityStage
from
"
@ohos.app.ability.AbilityStage
"
;
import
AbilityLifecycleCallback
from
'
@ohos.app.ability.AbilityLifecycleCallback
'
;
import
AbilityStage
from
'
@ohos.app.ability.AbilityStage
'
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
// 声明ability生命周期回调,需配置所有回调后才可以在applicationContext注册
let
abilityLifecycleCallback
=
{
onAbilityCreate
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityCreate.
"
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityCreate.
'
);
},
onWindowStageCreate
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageCreate.
"
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageCreate.
'
);
},
onWindowStageActive
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageActive.
"
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageActive.
'
);
},
onWindowStageInactive
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageInactive.
"
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageInactive.
'
);
},
onWindowStageDestroy
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageDestroy.
"
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageDestroy.
'
);
},
onAbilityDestroy
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityDestroy.
"
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityDestroy.
'
);
},
onAbilityForeground
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityForeground.
"
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityForeground.
'
);
},
onAbilityBackground
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityBackground.
"
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityBackground.
'
);
},
onAbilityContinue
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityContinue.
"
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityContinue.
'
);
}
};
export
default
class
MyFirstAbility
extends
UIAbility
{
onCreate
()
{
console
.
log
(
"
MyAbilityStage onCreate
"
);
console
.
log
(
'
MyAbilityStage onCreate
'
);
// 1.通过context属性获取applicationContext
let
applicationContext
=
this
.
context
.
getApplicationContext
();
// 2.通过applicationContext注册监听应用内生命周期
try
{
globalThis
.
lifecycleId
=
applicationContext
.
on
(
"
abilityLifecycle
"
,
abilityLifecycleCallback
);
console
.
log
(
"
registerAbilityLifecycleCallback number:
"
+
JSON
.
stringify
(
lifecycleId
));
globalThis
.
lifecycleId
=
applicationContext
.
on
(
'
abilityLifecycle
'
,
abilityLifecycleCallback
);
console
.
log
(
'
registerAbilityLifecycleCallback number:
'
+
JSON
.
stringify
(
lifecycleId
));
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
}
}
...
...
@@ -285,17 +285,17 @@ export default class MyFirstAbility extends UIAbility {
MySecondAbility.ts
```
ts
import
UIAbility
from
"
ohos.app.ability.UIAbility
"
;
import
UIAbility
from
'
ohos.app.ability.UIAbility
'
;
export
default
class
MySecondAbility
extends
UIAbility
{
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
// 3.通过applicationContext注销监听应用内生命周期
applicationContext
.
off
(
"
abilityLifecycle
"
,
globalThis
.
lifecycleId
,
(
error
)
=>
{
applicationContext
.
off
(
'
abilityLifecycle
'
,
globalThis
.
lifecycleId
,
(
error
)
=>
{
if
(
error
.
code
!=
0
)
{
console
.
log
(
"
unregisterAbilityLifecycleCallback failed, error:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
unregisterAbilityLifecycleCallback failed, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
console
.
log
(
"
unregisterAbilityLifecycleCallback success.
"
);
console
.
log
(
'
unregisterAbilityLifecycleCallback success.
'
);
}
});
}
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
浏览文件 @
b2011405
...
...
@@ -64,7 +64,7 @@ const config = {
language
:
'
Zh-Hans
'
,
// 简体中文
colorMode
:
COLOR_MODE_LIGHT
,
// 浅色模式
direction
:
DIRECTION_VERTICAL
,
// 垂直方向
screenDensity
:
SCREEN_DENSITY_SDPI
,
// 屏幕分辨率为
"sdpi"
screenDensity
:
SCREEN_DENSITY_SDPI
,
// 屏幕分辨率为
'sdpi'
displayId
:
1
,
// 应用在Id为1的物理屏上显示
hasPointerDevice
:
true
,
// 指针类型设备已连接
};
...
...
@@ -72,9 +72,9 @@ const config = {
try
{
abilityManager
.
updateConfiguration
(
config
,
(
err
)
=>
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
updateConfiguration fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
updateConfiguration fail, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
updateConfiguration success.
"
);
console
.
log
(
'
updateConfiguration success.
'
);
}
})
}
catch
(
paramError
)
{
...
...
@@ -122,7 +122,7 @@ const config = {
language
:
'
Zh-Hans
'
,
// 简体中文
colorMode
:
COLOR_MODE_LIGHT
,
// 浅色模式
direction
:
DIRECTION_VERTICAL
,
// 垂直方向
screenDensity
:
SCREEN_DENSITY_SDPI
,
// 屏幕分辨率为
"sdpi"
screenDensity
:
SCREEN_DENSITY_SDPI
,
// 屏幕分辨率为
'sdpi'
displayId
:
1
,
// 应用在Id为1的物理屏上显示
hasPointerDevice
:
true
,
// 指针类型设备已连接
};
...
...
@@ -171,9 +171,9 @@ import abilityManager from '@ohos.app.ability.abilityManager';
try
{
abilityManager
.
getAbilityRunningInfos
((
err
,
data
)
=>
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
getAbilityRunningInfos fail, error:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getAbilityRunningInfos fail, error:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
getAbilityRunningInfos success, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
getAbilityRunningInfos success, data:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
paramError
)
{
...
...
@@ -213,9 +213,9 @@ import abilityManager from '@ohos.app.ability.abilityManager';
try
{
abilityManager
.
getAbilityRunningInfos
().
then
((
data
)
=>
{
console
.
log
(
"
getAbilityRunningInfos success, data:
"
+
JSON
.
stringify
(
data
))
console
.
log
(
'
getAbilityRunningInfos success, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
log
(
"
getAbilityRunningInfos fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getAbilityRunningInfos fail, err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
paramError
)
{
console
.
log
(
'
error.code:
'
+
JSON
.
stringify
(
paramError
.
code
)
...
...
@@ -258,9 +258,9 @@ let upperLimit = 10;
try
{
abilityManager
.
getExtensionRunningInfos
(
upperLimit
,
(
err
,
data
)
=>
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
getExtensionRunningInfos fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getExtensionRunningInfos fail, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
getExtensionRunningInfos success, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
getExtensionRunningInfos success, data:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
paramError
)
{
...
...
@@ -308,9 +308,9 @@ let upperLimit = 10;
try
{
abilityManager
.
getExtensionRunningInfos
(
upperLimit
).
then
((
data
)
=>
{
console
.
log
(
"
getExtensionRunningInfos success, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
getExtensionRunningInfos success, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
log
(
"
getExtensionRunningInfos fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getExtensionRunningInfos fail, err:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
paramError
)
{
console
.
log
(
'
error.code:
'
+
JSON
.
stringify
(
paramError
.
code
)
...
...
@@ -347,9 +347,9 @@ import abilityManager from '@ohos.app.ability.abilityManager';
abilityManager
.
getTopAbility
((
err
,
data
)
=>
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
getTopAbility fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getTopAbility fail, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
getTopAbility success, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
getTopAbility success, data:
'
+
JSON
.
stringify
(
data
));
}
});
```
...
...
@@ -382,8 +382,8 @@ getTopAbility(): Promise\<ElementName>;
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
;
abilityManager
.
getTopAbility
().
then
((
data
)
=>
{
console
.
log
(
"
getTopAbility success, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
getTopAbility success, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
log
(
"
getTopAbility fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getTopAbility fail, err:
'
+
JSON
.
stringify
(
err
));
})
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-app-ability-abilityStage.md
浏览文件 @
b2011405
...
...
@@ -30,7 +30,7 @@ import AbilityStage from '@ohos.app.ability.AbilityStage';
class
MyAbilityStage
extends
AbilityStage
{
onCreate
()
{
console
.
log
(
"
MyAbilityStage.onCreate is called
"
);
console
.
log
(
'
MyAbilityStage.onCreate is called
'
);
}
}
```
...
...
@@ -63,8 +63,8 @@ import AbilityStage from '@ohos.app.ability.AbilityStage';
class
MyAbilityStage
extends
AbilityStage
{
onAcceptWant
(
want
)
{
console
.
log
(
"
MyAbilityStage.onAcceptWant called
"
);
return
"
com.example.test
"
;
console
.
log
(
'
MyAbilityStage.onAcceptWant called
'
);
return
'
com.example.test
'
;
}
}
```
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-appManager.md
浏览文件 @
b2011405
...
...
@@ -41,9 +41,9 @@ import appManager from '@ohos.app.ability.appManager';
appManager
.
isRunningInStabilityTest
((
err
,
flag
)
=>
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
isRunningInStabilityTest faile, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isRunningInStabilityTest faile, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
The result of isRunningInStabilityTest is:
"
+
JSON
.
stringify
(
flag
));
console
.
log
(
'
The result of isRunningInStabilityTest is:
'
+
JSON
.
stringify
(
flag
));
}
})
```
...
...
@@ -77,9 +77,9 @@ static isRunningInStabilityTest(): Promise<boolean>
import
appManager
from
'
@ohos.app.ability.appManager
'
;
appManager
.
isRunningInStabilityTest
().
then
((
flag
)
=>
{
console
.
log
(
"
The result of isRunningInStabilityTest is:
"
+
JSON
.
stringify
(
flag
));
console
.
log
(
'
The result of isRunningInStabilityTest is:
'
+
JSON
.
stringify
(
flag
));
}).
catch
((
error
)
=>
{
console
.
log
(
"
error:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
error:
'
+
JSON
.
stringify
(
error
));
});
```
...
...
@@ -112,9 +112,9 @@ isRamConstrainedDevice(): Promise\<boolean>;
import
appManager
from
'
@ohos.app.ability.appManager
'
;
appManager
.
isRamConstrainedDevice
().
then
((
data
)
=>
{
console
.
log
(
"
The result of isRamConstrainedDevice is:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
The result of isRamConstrainedDevice is:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
"
error:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
error:
'
+
JSON
.
stringify
(
error
));
});
```
...
...
@@ -147,9 +147,9 @@ import appManager from '@ohos.app.ability.appManager';
appManager
.
isRamConstrainedDevice
((
err
,
data
)
=>
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
isRamConstrainedDevice faile, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isRamConstrainedDevice faile, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
The result of isRamConstrainedDevice is:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
The result of isRamConstrainedDevice is:
'
+
JSON
.
stringify
(
data
));
}
})
```
...
...
@@ -182,9 +182,9 @@ getAppMemorySize(): Promise\<number>;
import
appManager
from
'
@ohos.app.ability.appManager
'
;
appManager
.
getAppMemorySize
().
then
((
data
)
=>
{
console
.
log
(
"
The size of app memory is:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
The size of app memory is:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
"
error:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
error:
'
+
JSON
.
stringify
(
error
));
});
```
...
...
@@ -217,9 +217,9 @@ import appManager from '@ohos.app.ability.appManager';
appManager
.
getAppMemorySize
((
err
,
data
)
=>
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
getAppMemorySize faile, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getAppMemorySize faile, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
The size of app memory is:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
The size of app memory is:
'
+
JSON
.
stringify
(
data
));
}
})
```
...
...
@@ -254,9 +254,9 @@ getRunningProcessInformation(): Promise\<Array\<ProcessInformation>>;
import
appManager
from
'
@ohos.app.ability.appManager
'
;
appManager
.
getRunningProcessInformation
().
then
((
data
)
=>
{
console
.
log
(
"
The running process information is:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
The running process information is:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
"
error:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
error:
'
+
JSON
.
stringify
(
error
));
});
```
...
...
@@ -291,16 +291,16 @@ import appManager from '@ohos.app.ability.appManager';
appManager
.
getRunningProcessInformation
((
err
,
data
)
=>
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
getRunningProcessInformation faile, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getRunningProcessInformation faile, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
The process running information is:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
The process running information is:
'
+
JSON
.
stringify
(
data
));
}
})
```
## appManager.on
on(type:
"applicationState"
, observer: ApplicationStateObserver): number;
on(type:
'applicationState'
, observer: ApplicationStateObserver): number;
注册全部应用程序的状态观测器。
...
...
@@ -314,7 +314,7 @@ on(type: "applicationState", observer: ApplicationStateObserver): number;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 调用接口类型,固定填
"applicationState"
字符串。 |
| type | string | 是 | 调用接口类型,固定填
'applicationState'
字符串。 |
| observer |
[
ApplicationStateObserver
](
./js-apis-inner-application-applicationStateObserver.md
)
| 是 | 应用状态观测器,用于观测应用的生命周期变化。 |
**返回值:**
...
...
@@ -363,7 +363,7 @@ try {
## appManager.on
on(type:
"applicationState"
, observer: ApplicationStateObserver, bundleNameList: Array
\<
string>): number;
on(type:
'applicationState'
, observer: ApplicationStateObserver, bundleNameList: Array
\<
string>): number;
注册指定应用程序的状态观测器。
...
...
@@ -377,7 +377,7 @@ on(type: "applicationState", observer: ApplicationStateObserver, bundleNameList:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 调用接口类型,固定填
"applicationState"
字符串。 |
| type | string | 是 | 调用接口类型,固定填
'applicationState'
字符串。 |
| observer |
[
ApplicationStateObserver
](
./js-apis-inner-application-applicationStateObserver.md
)
| 是 | 应用状态观测器,用于观测应用的生命周期变化。 |
| bundleNameList |
`Array<string>`
| 是 | 表示需要注册监听的bundleName数组。最大值128。 |
...
...
@@ -419,7 +419,7 @@ let applicationStateObserver = {
}
let
bundleNameList
=
[
'
bundleName1
'
,
'
bundleName2
'
];
try
{
const
observerId
=
appManager
.
on
(
"
applicationState
"
,
applicationStateObserver
,
bundleNameList
);
const
observerId
=
appManager
.
on
(
'
applicationState
'
,
applicationStateObserver
,
bundleNameList
);
console
.
log
(
`[appManager] observerCode:
${
observerId
}
`
);
}
catch
(
paramError
)
{
console
.
log
(
`[appManager] error:
${
paramError
.
code
}
,
${
paramError
.
message
}
`
);
...
...
@@ -428,7 +428,7 @@ try {
## appManager.off
off(type:
"applicationState"
, observerId: number, callback: AsyncCallback
\<
void>): void;
off(type:
'applicationState'
, observerId: number, callback: AsyncCallback
\<
void>): void;
取消注册应用程序状态观测器。
...
...
@@ -442,7 +442,7 @@ off(type: "applicationState", observerId: number, callback: AsyncCallback\<void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 调用接口类型,固定填
"applicationState"
字符串。 |
| type | string | 是 | 调用接口类型,固定填
'applicationState'
字符串。 |
| observerId | number | 是 | 表示观测器的编号代码。 |
| callback | AsyncCallback
\<
void> | 是 | 以回调方式返回接口运行结果,可进行错误处理或其他自定义处理。 |
...
...
@@ -481,7 +481,7 @@ let applicationStateObserver = {
}
let
bundleNameList
=
[
'
bundleName1
'
,
'
bundleName2
'
];
try
{
observerId
=
appManager
.
on
(
"
applicationState
"
,
applicationStateObserver
,
bundleNameList
);
observerId
=
appManager
.
on
(
'
applicationState
'
,
applicationStateObserver
,
bundleNameList
);
console
.
log
(
`[appManager] observerCode:
${
observerId
}
`
);
}
catch
(
paramError
)
{
console
.
log
(
`[appManager] error:
${
paramError
.
code
}
,
${
paramError
.
message
}
`
);
...
...
@@ -490,13 +490,13 @@ try {
// 2.注销应用状态监听器
function
unregisterApplicationStateObserverCallback
(
err
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
unregisterApplicationStateObserverCallback faile, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
unregisterApplicationStateObserverCallback faile, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
unregisterApplicationStateObserverCallback success.
"
);
console
.
log
(
'
unregisterApplicationStateObserverCallback success.
'
);
}
}
try
{
appManager
.
off
(
"
applicationState
"
,
observerId
,
unregisterApplicationStateObserverCallback
);
appManager
.
off
(
'
applicationState
'
,
observerId
,
unregisterApplicationStateObserverCallback
);
}
catch
(
paramError
)
{
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
...
...
@@ -504,7 +504,7 @@ try {
## appManager.off
off(type:
"applicationState"
, observerId: number): Promise
\<
void>;
off(type:
'applicationState'
, observerId: number): Promise
\<
void>;
取消注册应用程序状态观测器。
...
...
@@ -518,7 +518,7 @@ off(type: "applicationState", observerId: number): Promise\<void>;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 调用接口类型,固定填
"applicationState"
字符串。 |
| type | string | 是 | 调用接口类型,固定填
'applicationState'
字符串。 |
| observerId | number | 是 | 表示观测器的编号代码。 |
**返回值:**
...
...
@@ -562,7 +562,7 @@ let applicationStateObserver = {
}
let
bundleNameList
=
[
'
bundleName1
'
,
'
bundleName2
'
];
try
{
observerId
=
appManager
.
on
(
"
applicationState
"
,
applicationStateObserver
,
bundleNameList
);
observerId
=
appManager
.
on
(
'
applicationState
'
,
applicationStateObserver
,
bundleNameList
);
console
.
log
(
`[appManager] observerCode:
${
observerId
}
`
);
}
catch
(
paramError
)
{
console
.
log
(
`[appManager] error:
${
paramError
.
code
}
,
${
paramError
.
message
}
`
);
...
...
@@ -570,10 +570,10 @@ try {
// 2.注销应用状态监听器
try
{
appManager
.
off
(
"
applicationState
"
,
observerId
).
then
((
data
)
=>
{
console
.
log
(
"
unregisterApplicationStateObserver success, data:
"
+
JSON
.
stringify
(
data
));
appManager
.
off
(
'
applicationState
'
,
observerId
).
then
((
data
)
=>
{
console
.
log
(
'
unregisterApplicationStateObserver success, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
log
(
"
unregisterApplicationStateObserver faile, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
unregisterApplicationStateObserver faile, err:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
paramError
)
{
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
...
...
@@ -613,15 +613,15 @@ import appManager from '@ohos.app.ability.appManager';
function
getForegroundApplicationsCallback
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
getForegroundApplicationsCallback fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getForegroundApplicationsCallback fail, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
getForegroundApplicationsCallback success, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
getForegroundApplicationsCallback success, data:
'
+
JSON
.
stringify
(
data
));
}
}
try
{
appManager
.
getForegroundApplications
(
getForegroundApplicationsCallback
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -657,9 +657,9 @@ getForegroundApplications(): Promise\<Array\<AppStateData>>;
import
appManager
from
'
@ohos.app.ability.appManager
'
;
appManager
.
getForegroundApplications
().
then
((
data
)
=>
{
console
.
log
(
"
getForegroundApplications success, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
getForegroundApplications success, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
log
(
"
getForegroundApplications fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getForegroundApplications fail, err:
'
+
JSON
.
stringify
(
err
));
})
```
...
...
@@ -699,12 +699,12 @@ let bundleName = 'bundleName';
let
accountId
=
0
;
try
{
appManager
.
killProcessWithAccount
(
bundleName
,
accountId
).
then
(()
=>
{
console
.
log
(
"
killProcessWithAccount success
"
);
console
.
log
(
'
killProcessWithAccount success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
killProcessWithAccount fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
error
(
'
killProcessWithAccount fail, err:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
error
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -746,9 +746,9 @@ let bundleName = 'bundleName';
let
accountId
=
0
;
function
killProcessWithAccountCallback
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
killProcessWithAccountCallback fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
killProcessWithAccountCallback fail, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
killProcessWithAccountCallback success.
"
);
console
.
log
(
'
killProcessWithAccountCallback success.
'
);
}
}
appManager
.
killProcessWithAccount
(
bundleName
,
accountId
,
killProcessWithAccountCallback
);
...
...
@@ -789,15 +789,15 @@ import appManager from '@ohos.app.ability.appManager';
let
bundleName
=
'
bundleName
'
;
function
killProcessesByBundleNameCallback
(
err
,
data
)
{
if
(
err
.
code
!==
0
)
{
console
.
log
(
"
killProcessesByBundleNameCallback fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
killProcessesByBundleNameCallback fail, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
killProcessesByBundleNameCallback success.
"
);
console
.
log
(
'
killProcessesByBundleNameCallback success.
'
);
}
}
try
{
appManager
.
killProcessesByBundleName
(
bundleName
,
killProcessesByBundleNameCallback
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -841,12 +841,12 @@ import appManager from '@ohos.app.ability.appManager';
let
bundleName
=
'
bundleName
'
;
try
{
appManager
.
killProcessesByBundleName
(
bundleName
).
then
((
data
)
=>
{
console
.
log
(
"
killProcessesByBundleName success.
"
);
console
.
log
(
'
killProcessesByBundleName success.
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
killProcessesByBundleName fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
killProcessesByBundleName fail, err:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -885,15 +885,15 @@ import appManager from '@ohos.app.ability.appManager';
let
bundleName
=
'
bundleName
'
;
function
clearUpApplicationDataCallback
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
"
clearUpApplicationDataCallback fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
clearUpApplicationDataCallback fail, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
clearUpApplicationDataCallback success.
"
);
console
.
log
(
'
clearUpApplicationDataCallback success.
'
);
}
}
try
{
appManager
.
clearUpApplicationData
(
bundleName
,
clearUpApplicationDataCallback
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -937,12 +937,12 @@ import appManager from '@ohos.app.ability.appManager';
let
bundleName
=
'
bundleName
'
;
try
{
appManager
.
clearUpApplicationData
(
bundleName
).
then
((
data
)
=>
{
console
.
log
(
"
clearUpApplicationData success.
"
);
console
.
log
(
'
clearUpApplicationData success.
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
clearUpApplicationData fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
clearUpApplicationData fail, err:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
浏览文件 @
b2011405
...
...
@@ -97,15 +97,15 @@ import errorManager from '@ohos.app.ability.errorManager';
let
observer
=
{
onUnhandledException
(
errorMsg
)
{
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
)
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
)
;
appRecovery
.
restartApp
();
}
};
try
{
errorManager
.
on
(
"
error
"
,
observer
);
errorManager
.
on
(
'
error
'
,
observer
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -131,14 +131,14 @@ import errorManager from '@ohos.app.ability.errorManager';
let
observer
=
{
onUnhandledException
(
errorMsg
)
{
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
)
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
)
;
appRecovery
.
saveAppState
();
}
};
try
{
errorManager
.
on
(
"
error
"
,
observer
);
errorManager
.
on
(
'
error
'
,
observer
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
zh-cn/application-dev/reference/apis/js-apis-app-ability-common.md
浏览文件 @
b2011405
...
...
@@ -10,7 +10,7 @@ Common模块将二级模块API组织在一起方便开发者进行导出。
## 导入模块
```
ts
import
common
from
'
@ohos.app.ability.common
'
import
common
from
'
@ohos.app.ability.common
'
;
```
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
...
...
@@ -33,7 +33,7 @@ import common from '@ohos.app.ability.common'
**示例:**
```
ts
import
common
from
'
@ohos.app.ability.common
'
import
common
from
'
@ohos.app.ability.common
'
;
let
uiAbilityContext
:
common
.
UIAbilityContext
;
let
abilityStageContext
:
common
.
AbilityStageContext
;
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-configuration.md
浏览文件 @
b2011405
...
...
@@ -39,10 +39,10 @@
};
try
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
let
callbackId
=
applicationContext
.
on
(
"
environment
"
,
envCallback
);
console
.
log
(
"
callbackId:
"
+
callbackId
);
let
callbackId
=
applicationContext
.
on
(
'
environment
'
,
envCallback
);
console
.
log
(
'
callbackId:
'
+
callbackId
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md
浏览文件 @
b2011405
...
...
@@ -47,9 +47,9 @@ import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| SCREEN_DENSITY_NOT_SET | 0 | 未设置屏幕分辨率。 |
| SCREEN_DENSITY_SDPI | 120 | 屏幕分辨率为
"sdpi"
。 |
| SCREEN_DENSITY_MDPI | 160 | 屏幕分辨率为
"mdpi"
。 |
| SCREEN_DENSITY_LDPI | 240 | 屏幕分辨率为
"ldpi"
。 |
| SCREEN_DENSITY_XLDPI | 320 | 屏幕分辨率为
"xldpi"
。 |
| SCREEN_DENSITY_XXLDPI | 480 | 屏幕分辨率为
"xxldpi"
。 |
| SCREEN_DENSITY_XXXLDPI | 640 | 屏幕分辨率为
"xxxldpi"
。 |
| SCREEN_DENSITY_SDPI | 120 | 屏幕分辨率为
'sdpi'
。 |
| SCREEN_DENSITY_MDPI | 160 | 屏幕分辨率为
'mdpi'
。 |
| SCREEN_DENSITY_LDPI | 240 | 屏幕分辨率为
'ldpi'
。 |
| SCREEN_DENSITY_XLDPI | 320 | 屏幕分辨率为
'xldpi'
。 |
| SCREEN_DENSITY_XXLDPI | 480 | 屏幕分辨率为
'xxldpi'
。 |
| SCREEN_DENSITY_XXXLDPI | 640 | 屏幕分辨率为
'xxxldpi'
。 |
zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
浏览文件 @
b2011405
...
...
@@ -11,7 +11,7 @@ EnvironmentCallback模块提供应用上下文ApplicationContext对系统环境
## 导入模块
```
ts
import
EnvironmentCallback
from
"
@ohos.app.ability.EnvironmentCallback
"
;
import
EnvironmentCallback
from
'
@ohos.app.ability.EnvironmentCallback
'
;
```
...
...
@@ -33,29 +33,29 @@ onConfigurationUpdated(config: Configuration): void;
```
ts
import
Ability
from
"
@ohos.application.Ability
"
;
import
Ability
from
'
@ohos.application.Ability
'
;
let
callbackId
;
export
default
class
MyAbility
extends
Ability
{
onCreate
()
{
console
.
log
(
"
MyAbility onCreate
"
)
console
.
log
(
'
MyAbility onCreate
'
)
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
let
EnvironmentCallback
=
{
onConfigurationUpdated
(
config
){
console
.
log
(
"
onConfigurationUpdated config:
"
+
JSON
.
stringify
(
config
));
console
.
log
(
'
onConfigurationUpdated config:
'
+
JSON
.
stringify
(
config
));
},
}
// 1.获取applicationContext
let
applicationContext
=
globalThis
.
applicationContext
;
// 2.通过applicationContext注册监听应用内生命周期
callbackId
=
applicationContext
.
registerEnvironmentCallback
(
EnvironmentCallback
);
console
.
log
(
"
registerEnvironmentCallback number:
"
+
JSON
.
stringify
(
callbackId
));
console
.
log
(
'
registerEnvironmentCallback number:
'
+
JSON
.
stringify
(
callbackId
));
}
onDestroy
()
{
let
applicationContext
=
globalThis
.
applicationContext
;
applicationContext
.
unregisterEnvironmentCallback
(
callbackId
,
(
error
,
data
)
=>
{
console
.
log
(
"
unregisterEnvironmentCallback success, err:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
unregisterEnvironmentCallback success, err:
'
+
JSON
.
stringify
(
error
));
});
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md
浏览文件 @
b2011405
...
...
@@ -13,7 +13,7 @@ import errorManager from '@ohos.app.ability.errorManager'
## ErrorManager.on
on(type:
"error"
, observer: ErrorObserver): number;
on(type:
'error'
, observer: ErrorObserver): number;
注册错误观测器。
...
...
@@ -35,15 +35,15 @@ let observer = {
}
}
try
{
errorManager
.
on
(
"
error
"
,
observer
);
errorManager
.
on
(
'
error
'
,
observer
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
## ErrorManager.off
off(type:
"error"
, observerId: number, callback: AsyncCallback
\<
void>): void;
off(type:
'error'
, observerId: number, callback: AsyncCallback
\<
void>): void;
注销错误观测器。
...
...
@@ -68,15 +68,15 @@ function unregisterErrorObserverCallback(err) {
}
}
try
{
errorManager
.
off
(
"
error
"
,
observerId
,
unregisterErrorObserverCallback
);
errorManager
.
off
(
'
error
'
,
observerId
,
unregisterErrorObserverCallback
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
## ErrorManager.off
off(type:
"error"
, observerId: number): Promise
\<
void>;
off(type:
'error'
, observerId: number): Promise
\<
void>;
注销错误观测器。
...
...
@@ -100,7 +100,7 @@ off(type: "error", observerId: number): Promise\<void>;
```
js
let
observerId
=
100
;
try
{
errorManager
.
off
(
"
error
"
,
observerId
)
errorManager
.
off
(
'
error
'
,
observerId
)
.
then
((
data
)
=>
{
console
.
log
(
'
----------- unregisterErrorObserver success ----------
'
,
data
);
})
...
...
@@ -108,7 +108,7 @@ try {
console
.
log
(
'
----------- unregisterErrorObserver fail ----------
'
,
err
);
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
浏览文件 @
b2011405
...
...
@@ -18,7 +18,7 @@ ohos.permission.MANAGE_MISSIONS
## missionManager.on
on(type:
"mission"
, listener: MissionListener): number;
on(type:
'mission'
, listener: MissionListener): number;
注册系统任务状态监听。
...
...
@@ -44,25 +44,25 @@ on(type:"mission", listener: MissionListener): number;
```
ts
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)
}
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);
}
};
console
.
log
(
"
registerMissionListener
"
)
console
.
log
(
'
registerMissionListener
'
)
try
{
let
listenerid
=
missionManager
.
on
(
"
mission
"
,
listener
);
let
listenerid
=
missionManager
.
on
(
'
mission
'
,
listener
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
## missionManager.off
off(type:
"mission"
, listenerId: number, callback: AsyncCallback
<
void
>
): void;
off(type:
'mission'
, listenerId: number, callback: AsyncCallback
<
void
>
): void;
取消任务状态监听。
...
...
@@ -83,29 +83,29 @@ off(type: "mission", listenerId: number, callback: AsyncCallback<void>): v
```
ts
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)
}
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);
}
};
console
.
log
(
"
registerMissionListener
"
)
console
.
log
(
'
registerMissionListener
'
)
try
{
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
missionManager
.
unregisterMissionListener
(
listenerid
,
(
error
)
=>
{
console
.
log
(
"
unregisterMissionListener
"
);
console
.
log
(
'
unregisterMissionListener
'
);
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
## missionManager.off
off(type:
"mission"
, listenerId: number): Promise
<
void
>
;
off(type:
'mission'
, listenerId: number): Promise
<
void
>
;
取消任务状态监听,以promise方式返回执行结果。
...
...
@@ -131,14 +131,14 @@ off(type: "mission", listenerId: number): Promise<void>;
```
ts
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)
}
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);
}
};
console
.
log
(
"
registerMissionListener
"
)
console
.
log
(
'
registerMissionListener
'
)
try
{
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
...
...
@@ -146,7 +146,7 @@ off(type: "mission", listenerId: number): Promise<void>;
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -177,18 +177,18 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
let
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
""
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
console
.
log
(
"
getMissionInfo is called, error.code =
"
+
error
.
code
)
console
.
log
(
"
mission.missionId =
"
+
mission
.
missionId
);
console
.
log
(
"
mission.runningState =
"
+
mission
.
runningState
);
console
.
log
(
"
mission.lockedState =
"
+
mission
.
lockedState
);
console
.
log
(
"
mission.timestamp =
"
+
mission
.
timestamp
);
console
.
log
(
"
mission.label =
"
+
mission
.
label
);
console
.
log
(
"
mission.iconPath =
"
+
mission
.
iconPath
);
let
allMissions
=
missionManager
.
getMissionInfos
(
''
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
''
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
console
.
log
(
'
getMissionInfo is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
mission.missionId =
'
+
mission
.
missionId
);
console
.
log
(
'
mission.runningState =
'
+
mission
.
runningState
);
console
.
log
(
'
mission.lockedState =
'
+
mission
.
lockedState
);
console
.
log
(
'
mission.timestamp =
'
+
mission
.
timestamp
);
console
.
log
(
'
mission.label =
'
+
mission
.
label
);
console
.
log
(
'
mission.iconPath =
'
+
mission
.
iconPath
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -224,11 +224,11 @@ getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
let
mission
=
missionManager
.
getMissionInfo
(
""
,
10
).
catch
(
function
(
err
){
let
mission
=
missionManager
.
getMissionInfo
(
''
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -259,13 +259,13 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -301,11 +301,11 @@ getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionIn
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
let
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
let
allMissions
=
missionManager
.
getMissionInfos
(
''
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -336,19 +336,19 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
missionManager
.
getMissionSnapShot
(
''
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
'
getMissionSnapShot is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
bundleName =
'
+
snapshot
.
ability
.
bundleName
);
})
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -381,22 +381,22 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
let
snapshot
=
missionManager
.
getMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
let
snapshot
=
missionManager
.
getMissionSnapShot
(
''
,
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -423,22 +423,22 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getLowResolutionMissionSnapShot is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
missionManager
.
getLowResolutionMissionSnapShot
(
''
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
'
getLowResolutionMissionSnapShot is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
bundleName =
'
+
snapshot
.
ability
.
bundleName
);
})
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -471,22 +471,22 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<M
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
let
snapshot
=
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
let
snapshot
=
missionManager
.
getLowResolutionMissionSnapShot
(
''
,
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -513,21 +513,21 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void;
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
lockMission is called
"
);
console
.
log
(
'
lockMission is called
'
);
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -559,22 +559,22 @@ lockMission(missionId: number): Promise<void>;
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -601,21 +601,21 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void;
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
unlockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
unlockMission is called
"
);
console
.
log
(
'
unlockMission is called
'
);
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -647,15 +647,15 @@ unlockMission(missionId: number): Promise<void>;
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
catch
(
function
(
err
){
...
...
@@ -665,7 +665,7 @@ unlockMission(missionId: number): Promise<void>;
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -692,21 +692,21 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void;
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
clearMission
(
id
).
then
(()
=>
{
console
.
log
(
"
clearMission is called
"
);
console
.
log
(
'
clearMission is called
'
);
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -738,22 +738,22 @@ clearMission(missionId: number): Promise<void>;
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
clearMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -773,10 +773,10 @@ clearAllMissions(callback: AsyncCallback<void>): void;
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
missionManager
.
clearAllMissions
().
then
(()
=>
{
console
.
log
(
"
clearAllMissions is called
"
);
console
.
log
(
'
clearAllMissions is called
'
);
});
```
...
...
@@ -802,7 +802,7 @@ clearAllMissions(): Promise<void>;
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
missionManager
.
clearAllMissions
().
catch
(
function
(
err
){
console
.
log
(
err
);
});
...
...
@@ -831,21 +831,21 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
console
.
log
(
'
moveMissionToFront is called
'
);
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -873,21 +873,21 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
,{
windowMode
:
101
}).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
console
.
log
(
'
moveMissionToFront is called
'
);
});
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -920,21 +920,21 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise<void&g
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md
浏览文件 @
b2011405
...
...
@@ -67,19 +67,19 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<v
**示例:**
```
ts
import
quickFixManager
from
'
@ohos.app.ability.quickFixManager
'
import
quickFixManager
from
'
@ohos.app.ability.quickFixManager
'
;
try
{
let
hapModuleQuickFixFiles
=
[
"
/data/storage/el2/base/entry.hqf
"
]
let
hapModuleQuickFixFiles
=
[
'
/data/storage/el2/base/entry.hqf
'
];
quickFixManager
.
applyQuickFix
(
hapModuleQuickFixFiles
,
(
error
)
=>
{
if
(
error
)
{
console
.
info
(
`applyQuickFix failed with error +
${
error
}
`
)
console
.
info
(
`applyQuickFix failed with error +
${
error
}
`
)
;
}
else
{
console
.
info
(
'
applyQuickFix success
'
)
console
.
info
(
'
applyQuickFix success
'
)
;
}
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -110,17 +110,17 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>;
**示例:**
```
ts
import
quickFixManager
from
'
@ohos.app.ability.quickFixManager
'
import
quickFixManager
from
'
@ohos.app.ability.quickFixManager
'
;
let
hapModuleQuickFixFiles
=
[
"
/data/storage/el2/base/entry.hqf
"
]
let
hapModuleQuickFixFiles
=
[
'
/data/storage/el2/base/entry.hqf
'
];
try
{
quickFixManager
.
applyQuickFix
(
hapModuleQuickFixFiles
).
then
(()
=>
{
console
.
info
(
'
applyQuickFix success
'
)
console
.
info
(
'
applyQuickFix success
'
)
;
}).
catch
((
error
)
=>
{
console
.
info
(
`applyQuickFix err: +
${
error
}
`
)
console
.
info
(
`applyQuickFix err: +
${
error
}
`
)
;
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -146,19 +146,19 @@ getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<Applicat
**示例:**
```
ts
import
quickFixManager
from
'
@ohos.app.ability.quickFixManager
'
import
quickFixManager
from
'
@ohos.app.ability.quickFixManager
'
;
try
{
let
bundleName
=
"
bundleName
"
let
bundleName
=
'
bundleName
'
quickFixManager
.
getApplicationQuickFixInfo
(
bundleName
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
info
(
`getApplicationQuickFixInfo error: +
${
error
}
`
)
console
.
info
(
`getApplicationQuickFixInfo error: +
${
error
}
`
)
;
}
else
{
console
.
info
(
`getApplicationQuickFixInfo success: +
${
data
}
`
)
console
.
info
(
`getApplicationQuickFixInfo success: +
${
data
}
`
)
;
}
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -189,16 +189,16 @@ getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo
**示例:**
```
ts
import
quickFixManager
from
'
@ohos.app.ability.quickFixManager
'
import
quickFixManager
from
'
@ohos.app.ability.quickFixManager
'
;
try
{
let
bundleName
=
"
bundleName
"
let
bundleName
=
'
bundleName
'
;
quickFixManager
.
getApplicationQuickFixInfo
(
bundleName
).
then
((
data
)
=>
{
console
.
info
(
`getApplicationQuickFixInfo success: +
${
data
}
`
)
console
.
info
(
`getApplicationQuickFixInfo success: +
${
data
}
`
)
;
}).
catch
((
error
)
=>
{
console
.
info
(
`getApplicationQuickFixInfo err: +
${
error
}
`
)
console
.
info
(
`getApplicationQuickFixInfo err: +
${
error
}
`
)
;
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
zh-cn/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
浏览文件 @
b2011405
...
...
@@ -129,7 +129,7 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC
**示例:**
```
ts
import
rpc
from
'
@ohos.rpc
'
import
rpc
from
'
@ohos.rpc
'
;
class
StubTest
extends
rpc
.
RemoteObject
{
constructor
(
des
)
{
super
(
des
);
...
...
@@ -140,7 +140,7 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC
class
ServiceExt
extends
ServiceExtension
{
onConnect
(
want
)
{
console
.
log
(
'
onConnect , want:
'
+
want
.
abilityName
);
return
new
StubTest
(
"
test
"
);
return
new
StubTest
(
'
test
'
);
}
}
```
...
...
@@ -246,7 +246,7 @@ onDump(params: Array\<string>): Array\<string>;
class
ServiceExt
extends
ServiceExtension
{
onDump
(
params
)
{
console
.
log
(
'
dump, params:
'
+
JSON
.
stringify
(
params
));
return
[
"
params
"
]
return
[
'
params
'
];
}
}
```
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-startOptions.md
浏览文件 @
b2011405
...
...
@@ -31,14 +31,14 @@ import StartOptions from '@ohos.app.ability.StartOptions';
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfos failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
console
.
log
(
'
getMissionInfos failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
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
=
{
...
...
@@ -46,10 +46,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
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
浏览文件 @
b2011405
...
...
@@ -204,11 +204,11 @@ onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
**示例:**
```
ts
import
AbilityConstant
from
"
@ohos.app.ability.AbilityConstant
"
import
AbilityConstant
from
'
@ohos.app.ability.AbilityConstant
'
;
class
MyUIAbility
extends
UIAbility
{
onContinue
(
wantParams
)
{
console
.
log
(
'
onContinue
'
);
wantParams
[
"
myData
"
]
=
"
my1234567
"
;
wantParams
[
'
myData
'
]
=
'
my1234567
'
;
return
AbilityConstant
.
OnContinueResult
.
AGREE
;
}
}
...
...
@@ -261,7 +261,7 @@ onDump(params: Array\<string>): Array\<string>;
class
myAbility
extends
Ability
{
onDump
(
params
)
{
console
.
log
(
'
dump, params:
'
+
JSON
.
stringify
(
params
));
return
[
"
params
"
]
return
[
'
params
'
];
}
}
```
...
...
@@ -291,12 +291,12 @@ onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any})
**示例:**
```
ts
import
AbilityConstant
from
'
@ohos.app.ability.AbilityConstant
'
import
AbilityConstant
from
'
@ohos.app.ability.AbilityConstant
'
;
class
MyUIAbility
extends
UIAbility
{
onSaveState
(
reason
,
wantParam
)
{
console
.
log
(
'
onSaveState
'
);
wantParam
[
"
myData
"
]
=
"
my1234567
"
;
wantParam
[
'
myData
'
]
=
'
my1234567
'
;
return
AbilityConstant
.
OnSaveResult
.
RECOVERY_AGREE
;
}
}
...
...
@@ -341,8 +341,8 @@ call(method: string, data: rpc.Sequenceable): Promise<void>;
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
class
MyMessageAble
{
// 自定义的Sequenceable数据结构
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -366,12 +366,12 @@ call(method: string, data: rpc.Sequenceable): Promise<void>;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
let
msg
=
new
MyMessageAble
(
"
msg
"
,
"
world
"
);
// 参考Sequenceable数据定义
let
msg
=
new
MyMessageAble
(
'
msg
'
,
'
world
'
);
// 参考Sequenceable数据定义
caller
.
call
(
method
,
msg
)
.
then
(()
=>
{
console
.
log
(
'
Caller call() called
'
);
...
...
@@ -422,8 +422,8 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
class
MyMessageAble
{
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -447,16 +447,16 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
let
msg
=
new
MyMessageAble
(
1
,
"
world
"
);
let
msg
=
new
MyMessageAble
(
1
,
'
world
'
);
caller
.
callWithResult
(
method
,
msg
)
.
then
((
data
)
=>
{
console
.
log
(
'
Caller callWithResult() called
'
);
let
retmsg
=
new
MyMessageAble
(
0
,
""
);
let
retmsg
=
new
MyMessageAble
(
0
,
''
);
data
.
readSequenceable
(
retmsg
);
})
.
catch
((
callErr
)
=>
{
...
...
@@ -497,9 +497,9 @@ release(): void;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
...
...
@@ -538,9 +538,9 @@ release(): void;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
...
...
@@ -561,7 +561,7 @@ release(): void;
## Caller.on
on(type:
"release"
, callback: OnReleaseCallback): void;
on(type:
'release'
, callback: OnReleaseCallback): void;
注册通用组件服务端Stub(桩)断开监听通知。
...
...
@@ -589,13 +589,13 @@ release(): void;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
caller
.
on
(
"
release
"
,
(
str
)
=>
{
caller
.
on
(
'
release
'
,
(
str
)
=>
{
console
.
log
(
'
Caller OnRelease CallBack is called
'
+
str
);
});
}
catch
(
error
)
{
...
...
@@ -612,7 +612,7 @@ release(): void;
## Caller.off
off(type:
"release"
, callback: OnReleaseCallback): void;
off(type:
'release'
, callback: OnReleaseCallback): void;
取消注册通用组件服务端Stub(桩)断开监听通知。预留能力,当前暂未支持。
...
...
@@ -639,17 +639,17 @@ off(type: "release", callback: OnReleaseCallback): void;
export
default
class
MainUIAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainUIAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainUIAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
let
onReleaseCallBack
=
(
str
)
=>
{
console
.
log
(
'
Caller OnRelease CallBack is called
'
+
str
);
};
caller
.
on
(
"
release
"
,
onReleaseCallBack
);
caller
.
off
(
"
release
"
,
onReleaseCallBack
);
caller
.
on
(
'
release
'
,
onReleaseCallBack
);
caller
.
off
(
'
release
'
,
onReleaseCallBack
);
}
catch
(
error
)
{
console
.
log
(
'
Caller.on or Caller.off catch error, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
...
...
@@ -664,7 +664,7 @@ off(type: "release", callback: OnReleaseCallback): void;
## Caller.off
off(type:
"release"
): void;
off(type:
'release'
): void;
取消注册通用组件服务端Stub(桩)断开监听通知。预留能力,当前暂未支持。
...
...
@@ -690,17 +690,17 @@ off(type: "release"): void;
export
default
class
MainUIAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainUIAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainUIAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
let
onReleaseCallBack
=
(
str
)
=>
{
console
.
log
(
'
Caller OnRelease CallBack is called
'
+
str
);
};
caller
.
on
(
"
release
"
,
onReleaseCallBack
);
caller
.
off
(
"
release
"
);
caller
.
on
(
'
release
'
,
onReleaseCallBack
);
caller
.
off
(
'
release
'
);
}
catch
(
error
)
{
console
.
error
(
'
Caller.on or Caller.off catch error, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
...
...
@@ -744,8 +744,8 @@ on(method: string, callback: CalleeCallback): void;
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
class
MyMessageAble
{
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -767,9 +767,9 @@ on(method: string, callback: CalleeCallback): void;
let
method
=
'
call_Function
'
;
function
funcCallBack
(
pdata
)
{
console
.
log
(
'
Callee funcCallBack is called
'
+
pdata
);
let
msg
=
new
MyMessageAble
(
"
test
"
,
""
);
let
msg
=
new
MyMessageAble
(
'
test
'
,
''
);
pdata
.
readSequenceable
(
msg
);
return
new
MyMessageAble
(
"
test1
"
,
"
Callee test
"
);
return
new
MyMessageAble
(
'
test1
'
,
'
Callee test
'
);
}
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md
浏览文件 @
b2011405
...
...
@@ -22,7 +22,7 @@ import Want from '@ohos.app.ability.Want';
| bundleName | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 |
| abilityName | string | 否 | 表示待启动的Ability名称。如果在Want中该字段同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。AbilityName需要在一个应用的范围内保证唯一。 |
| uri | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 |
| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:
"text/xml" 、 "image/
*
"
等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:
'text/xml' 、 'image/
*
'
等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| flags | number | 否 | 表示处理Want的方式。默认传数字,具体参考:
[
flags说明
](
js-apis-ability-wantConstant.md#wantConstant.Flags
)
。 |
| action | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。 |
| parameters | {
[
key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br />- ohos.aafwk.callerPid:表示拉起方的pid。<br />- ohos.aafwk.param.callerToken:表示拉起方的token。<br />- ohos.aafwk.param.callerUid:表示[BundleInfo
](
js-apis-bundleManager-bundleInfo.md#bundleinfo-1
)
中的uid,应用包里应用程序的uid。
<br
/>
- component.startup.newRules:表示是否启用新的管控规则。
<br
/>
- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。
<br
/>
- ohos.dlp.params.sandbox:表示dlp文件才会有。 | |
...
...
@@ -35,14 +35,14 @@ import Want from '@ohos.app.ability.Want';
```
ts
var
want
=
{
"
deviceId
"
:
""
,
// deviceId为空表示本设备
"
bundleName
"
:
"
com.extreme.test
"
,
"
abilityName
"
:
"
MainAbility
"
,
"
moduleName
"
:
"
entry
"
// moduleName非必选
'
deviceId
'
:
''
,
// deviceId为空表示本设备
'
bundleName
'
:
'
com.extreme.test
'
,
'
abilityName
'
:
'
MainAbility
'
,
'
moduleName
'
:
'
entry
'
// moduleName非必选
};
this
.
context
.
startAbility
(
want
,
(
error
)
=>
{
// 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability
console
.
log
(
"
error.code =
"
+
error
.
code
)
console
.
log
(
'
error.code =
'
+
error
.
code
);
})
```
...
...
@@ -51,84 +51,84 @@ import Want from '@ohos.app.ability.Want';
* 字符串(String)
```ts
let want = {
bundleName:
"com.example.demo"
,
abilityName:
"com.example.demo.MainAbility"
,
bundleName:
'com.example.demo'
,
abilityName:
'com.example.demo.MainAbility'
,
parameters: {
keyForString:
"str"
,
keyForString:
'str'
,
},
}
}
;
```
* 数字(Number)
```ts
let want = {
bundleName:
"com.example.demo"
,
abilityName:
"com.example.demo.MainAbility"
,
bundleName:
'com.example.demo'
,
abilityName:
'com.example.demo.MainAbility'
,
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
}
}
;
```
* 布尔(Boolean)
```ts
let want = {
bundleName:
"com.example.demo"
,
abilityName:
"com.example.demo.MainAbility"
,
bundleName:
'com.example.demo'
,
abilityName:
'com.example.demo.MainAbility'
,
parameters: {
keyForBool: true,
},
}
}
;
```
* 对象(Object)
```ts
let want = {
bundleName:
"com.example.demo"
,
abilityName:
"com.example.demo.MainAbility"
,
bundleName:
'com.example.demo'
,
abilityName:
'com.example.demo.MainAbility'
,
parameters: {
keyForObject: {
keyForObjectString:
"str"
,
keyForObjectString:
'str'
,
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
},
}
}
;
```
* 数组(Array)
```ts
let want = {
bundleName:
"com.example.demo"
,
abilityName:
"com.example.demo.MainAbility"
,
bundleName:
'com.example.demo'
,
abilityName:
'com.example.demo.MainAbility'
,
parameters: {
keyForArrayString: [
"str1", "str2", "str3"
],
keyForArrayString: [
'str1', 'str2', 'str3'
],
keyForArrayInt: [100, 200, 300, 400],
keyForArrayDouble: [0.1, 0.2],
keyForArrayObject: [{obj1:
"aaa"
}, {obj2: 100}],
keyForArrayObject: [{obj1:
'aaa'
}, {obj2: 100}],
},
}
}
;
```
* 文件描述符(FD)
```ts
import fileio from '@ohos.fileio';
var fd;
try {
fd = fileio.openSync(
"/data/storage/el2/base/haps/pic.png"
);
fd = fileio.openSync(
'/data/storage/el2/base/haps/pic.png'
);
} catch(e) {
console.log(
"openSync fail:"
+ JSON.stringify(e));
console.log(
'openSync fail:'
+ JSON.stringify(e));
}
var want = {
"deviceId": ""
, // deviceId为空表示本设备
"bundleName": "com.extreme.test"
,
"abilityName": "MainAbility"
,
"moduleName": "entry"
, // moduleName非必选
"parameters"
: {
"keyFd":{"type":"FD", "value":fd} // {"type":"FD", "value"
:fd}是固定用法,用于表示该数据是FD
'deviceId': ''
, // deviceId为空表示本设备
'bundleName': 'com.extreme.test'
,
'abilityName': 'MainAbility'
,
'moduleName': 'entry'
, // moduleName非必选
'parameters'
: {
'keyFd':{'type':'FD', 'value':fd} // {'type':'FD', 'value'
:fd}是固定用法,用于表示该数据是FD
}
};
this.context.startAbility(want, (error) => {
// 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability
console.log(
"error.code = " + error.code)
})
console.log(
'error.code = ' + error.code);
})
;
```
<!--no_check-->
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
浏览文件 @
b2011405
...
...
@@ -34,27 +34,27 @@ import WantAgent from '@ohos.app.ability.wantAgent';
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
}
//WantAgentInfo对象
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -65,9 +65,9 @@ var wantAgentInfo = {
}
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
;
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -103,21 +103,21 @@ import WantAgent from '@ohos.app.ability.wantAgent';
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -125,14 +125,14 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -164,7 +164,7 @@ var wantAgent;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
wantAgent
=
data
;
}
else
{
...
...
@@ -175,21 +175,21 @@ function getWantAgentCallback(err, data) {
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -197,18 +197,18 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
;
//getBundleName回调
function
getBundleNameCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getBundleNameCallback=======================>
"
);
console
.
info
(
'
==========================>getBundleNameCallback=======================>
'
);
}
WantAgent
.
getBundleName
(
wantAgent
,
getBundleNameCallback
)
WantAgent
.
getBundleName
(
wantAgent
,
getBundleNameCallback
)
;
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -247,21 +247,21 @@ var wantAgent;
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -269,19 +269,19 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
});
WantAgent
.
getBundleName
(
wantAgent
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getBundleNameCallback=======================>
"
);
console
.
info
(
'
==========================>getBundleNameCallback=======================>
'
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -313,7 +313,7 @@ var wantAgent;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
wantAgent
=
data
;
}
else
{
...
...
@@ -324,21 +324,21 @@ function getWantAgentCallback(err, data) {
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -346,18 +346,18 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
;
//getUid回调
function
getUidCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getUidCallback=======================>
"
);
console
.
info
(
'
==========================>getUidCallback=======================>
'
);
}
WantAgent
.
getUid
(
wantAgent
,
getUidCallback
)
WantAgent
.
getUid
(
wantAgent
,
getUidCallback
)
;
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -396,21 +396,21 @@ var wantAgent;
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -418,19 +418,19 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
});
WantAgent
.
getUid
(
wantAgent
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getUidCallback=======================>
"
);
console
.
info
(
'
==========================>getUidCallback=======================>
'
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -464,7 +464,7 @@ var wantAgent;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
wantAgent
=
data
;
}
else
{
...
...
@@ -475,21 +475,21 @@ function getWantAgentCallback(err, data) {
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -497,18 +497,18 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
;
//getWant回调
function
getWantCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantCallback=======================>
"
);
console
.
info
(
'
==========================>getWantCallback=======================>
'
);
}
WantAgent
.
getWant
(
wantAgent
,
getWantCallback
)
WantAgent
.
getWant
(
wantAgent
,
getWantCallback
)
;
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -549,21 +549,21 @@ var wantAgent;
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -571,19 +571,19 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
});
WantAgent
.
getWant
(
wantAgent
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantCallback=======================>
"
);
console
.
info
(
'
==========================>getWantCallback=======================>
'
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -615,7 +615,7 @@ var wantAgent;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
wantAgent
=
data
;
}
else
{
...
...
@@ -626,21 +626,21 @@ function getWantAgentCallback(err, data) {
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -648,18 +648,18 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
;
//cancel回调
function
cancelCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>cancelCallback=======================>
"
);
console
.
info
(
'
==========================>cancelCallback=======================>
'
);
}
WantAgent
.
cancel
(
wantAgent
,
cancelCallback
)
WantAgent
.
cancel
(
wantAgent
,
cancelCallback
)
;
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -698,21 +698,21 @@ var wantAgent;
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -720,19 +720,19 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
});
WantAgent
.
cancel
(
wantAgent
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>cancelCallback=======================>
"
);
console
.
info
(
'
==========================>cancelCallback=======================>
'
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -765,7 +765,7 @@ var wantAgent;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
wantAgent
=
data
;
}
else
{
...
...
@@ -776,21 +776,21 @@ function getWantAgentCallback(err, data) {
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -798,23 +798,23 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
;
//trigger回调
function
triggerCallback
(
data
)
{
console
.
info
(
"
==========================>triggerCallback=======================>
"
);
console
.
info
(
'
==========================>triggerCallback=======================>
'
);
}
var
triggerInfo
=
{
code
:
0
}
WantAgent
.
trigger
(
wantAgent
,
triggerInfo
,
triggerCallback
)
}
;
WantAgent
.
trigger
(
wantAgent
,
triggerInfo
,
triggerCallback
)
;
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -848,7 +848,7 @@ var wantAgent2;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
wantAgent1
=
data
;
wantAgent2
=
data
;
...
...
@@ -860,21 +860,21 @@ function getWantAgentCallback(err, data) {
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -882,18 +882,18 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
;
//equal回调
function
equalCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>equalCallback=======================>
"
);
console
.
info
(
'
==========================>equalCallback=======================>
'
);
}
WantAgent
.
equal
(
wantAgent1
,
wantAgent2
,
equalCallback
)
WantAgent
.
equal
(
wantAgent1
,
wantAgent2
,
equalCallback
)
;
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -934,21 +934,21 @@ var wantAgent2;
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -956,20 +956,20 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent1
=
data
;
wantAgent2
=
data
;
});
WantAgent
.
equal
(
wantAgent1
,
wantAgent2
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>equalCallback=======================>
"
);
console
.
info
(
'
==========================>equalCallback=======================>
'
);
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -1000,21 +1000,21 @@ var wantAgent;
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -1022,11 +1022,11 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
});
...
...
@@ -1034,7 +1034,7 @@ try {
console
.
log
(
'
----------- getOperationType ----------, OperationType:
'
+
OperationType
);
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
@@ -1070,21 +1070,21 @@ var wantAgent;
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
}
}
...
...
@@ -1092,11 +1092,11 @@ var wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
});
...
...
@@ -1106,7 +1106,7 @@ try {
console
.
log
(
'
getOperationType fail, err:
'
+
err
);
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md
浏览文件 @
b2011405
...
...
@@ -8,7 +8,7 @@ wantConstant模块提供want中操作want常数和解释Flags说明的能力。
## 导入模块
```
j
s
```
t
s
import
wantConstant
from
'
@ohos.app.ability.wantConstant
'
;
```
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md
浏览文件 @
b2011405
...
...
@@ -35,7 +35,7 @@ createFormBindingData(obj?: Object | string): FormBindingData
| 参数名 | 类型 | 必填 | 说明 |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| obj | Object
\|
string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以
"formImages"作为标识,内容为图片标识与图片文件描述符的键值对{"formImages": {"key1": fd1, "key2"
: fd2}} |
| obj | Object
\|
string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以
'formImages'作为标识,内容为图片标识与图片文件描述符的键值对{'formImages': {'key1': fd1, 'key2'
: fd2}} |
**返回值:**
...
...
@@ -52,11 +52,11 @@ import featureAbility from '@ohos.ability.featureAbility';
import
fileio
from
'
@ohos.fileio
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
((
err
,
data
)
=>
{
let
path
=
data
+
"
/xxx.jpg
"
;
let
path
=
data
+
'
/xxx.jpg
'
;
let
fd
=
fileio
.
openSync
(
path
);
let
obj
=
{
"
temperature
"
:
"
21°
"
,
"
formImages
"
:
{
"
image
"
:
fd
}
'
temperature
'
:
'
21°
'
,
'
formImages
'
:
{
'
image
'
:
fd
}
};
try
{
formBindingData
.
createFormBindingData
(
obj
);
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
浏览文件 @
b2011405
...
...
@@ -49,8 +49,8 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm
(
want
)
{
console
.
log
(
'
FormExtensionAbility onAddForm, want:
'
+
want
.
abilityName
);
let
dataObj1
=
{
temperature
:
"
11c
"
,
"
time
"
:
"
11:00
"
temperature
:
'
11c
'
,
'
time
'
:
'
11:00
'
};
let
obj1
=
formBindingData
.
createFormBindingData
(
dataObj1
);
return
obj1
;
...
...
@@ -99,11 +99,11 @@ onUpdateForm(formId: string): void
**示例:**
```
ts
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onUpdateForm
(
formId
)
{
console
.
log
(
'
FormExtensionAbility onUpdateForm, formId:
'
+
formId
);
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
this
.
context
.
updateForm
(
formId
,
obj2
).
then
((
data
)
=>
{
console
.
log
(
'
FormExtensionAbility context updateForm, data:
'
+
data
);
}).
catch
((
error
)
=>
{
...
...
@@ -129,14 +129,14 @@ onChangeFormVisibility(newStatus: { [key: string]: number }): void
**示例:**
```
ts
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onChangeFormVisibility
(
newStatus
)
{
console
.
log
(
'
FormExtensionAbility onChangeFormVisibility, newStatus:
'
+
newStatus
);
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
for
(
let
key
in
newStatus
)
{
console
.
log
(
'
FormExtensionAbility onChangeFormVisibility, key:
'
+
key
+
"
, value=
"
+
newStatus
[
key
]);
console
.
log
(
'
FormExtensionAbility onChangeFormVisibility, key:
'
+
key
+
'
, value=
'
+
newStatus
[
key
]);
this
.
context
.
updateForm
(
key
,
obj2
).
then
((
data
)
=>
{
console
.
log
(
'
FormExtensionAbility context updateForm, data:
'
+
data
);
}).
catch
((
error
)
=>
{
...
...
@@ -166,7 +166,7 @@ onFormEvent(formId: string, message: string): void
```
ts
export
default
class
MyFormExtension
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
"
, message:
"
+
message
);
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
'
, message:
'
+
message
);
}
}
```
...
...
@@ -274,8 +274,8 @@ class MyFormExtensionAbility extends FormExtensionAbility {
onShareForm
(
formId
)
{
console
.
log
(
'
FormExtensionAbility onShareForm, formId:
'
+
formId
);
let
wantParams
=
{
"
temperature
"
:
"
20
"
,
"
time
"
:
"
2022-8-8 09:59
"
,
'
temperature
'
:
'
20
'
,
'
time
'
:
'
2022-8-8 09:59
'
,
};
return
wantParams
;
}
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md
浏览文件 @
b2011405
...
...
@@ -41,7 +41,7 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost deleteForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -89,7 +89,7 @@ deleteForm(formId: string): Promise<void>
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost deleteForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -128,7 +128,7 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost releaseForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -168,7 +168,7 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost releaseForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -213,7 +213,7 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost releaseForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -252,7 +252,7 @@ requestForm(formId: string, callback: AsyncCallback<void>): void
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost requestForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -296,7 +296,7 @@ requestForm(formId: string): Promise<void>
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost requestForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -336,7 +336,7 @@ castToNormalForm(formId: string, callback: AsyncCallback<void>): void
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
castToNormalForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost castTempForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -380,7 +380,7 @@ castToNormalForm(formId: string): Promise<void>
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
castToNormalForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost castTempForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -419,7 +419,7 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost notifyVisibleForms, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -463,7 +463,7 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyVisibleForms success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -502,7 +502,7 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost notifyInvisibleForms, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -546,7 +546,7 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyInvisibleForms success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -585,7 +585,7 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void&
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost enableFormsUpdate, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -629,7 +629,7 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost enableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -668,7 +668,7 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost disableFormsUpdate, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -712,7 +712,7 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost disableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -741,7 +741,7 @@ isSystemReady(callback: AsyncCallback<void>): void
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
isSystemReady
((
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost isSystemReady, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -770,7 +770,7 @@ isSystemReady(): Promise<void>
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
isSystemReady
().
then
(()
=>
{
console
.
log
(
'
formHost isSystemReady success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -871,7 +871,7 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo
```
ts
try
{
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
...
...
@@ -912,7 +912,7 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<
```
ts
try
{
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
"
entry
"
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
...
...
@@ -958,7 +958,7 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI
```
ts
try
{
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
"
entry
"
).
then
((
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
).
then
((
data
)
=>
{
console
.
log
(
'
formHost getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -989,7 +989,7 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb
```
ts
try
{
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost deleteInvalidForms, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -1028,7 +1028,7 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>
```
ts
try
{
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
).
then
((
data
)
=>
{
console
.
log
(
'
formHost deleteInvalidForms, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -1067,13 +1067,13 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g
```
ts
var
want
=
{
"
deviceId
"
:
""
,
"
bundleName
"
:
"
ohos.samples.FormApplication
"
,
"
abilityName
"
:
"
FormAbility
"
,
"
parameters
"
:
{
"
ohos.extra.param.key.module_name
"
:
"
entry
"
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.form_dimension
"
:
2
'
deviceId
'
:
''
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
abilityName
'
:
'
FormAbility
'
,
'
parameters
'
:
{
'
ohos.extra.param.key.module_name
'
:
'
entry
'
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.form_dimension
'
:
2
}
};
try
{
...
...
@@ -1122,13 +1122,13 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
```
ts
var
want
=
{
"
deviceId
"
:
""
,
"
bundleName
"
:
"
ohos.samples.FormApplication
"
,
"
abilityName
"
:
"
FormAbility
"
,
"
parameters
"
:
{
"
ohos.extra.param.key.module_name
"
:
"
entry
"
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.form_dimension
"
:
2
'
deviceId
'
:
''
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
abilityName
'
:
'
FormAbility
'
,
'
parameters
'
:
{
'
ohos.extra.param.key.module_name
'
:
'
entry
'
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.form_dimension
'
:
2
}
};
try
{
...
...
@@ -1142,9 +1142,9 @@ try {
}
```
## on(
"formUninstall"
)
## on(
'formUninstall'
)
on(type:
"formUninstall"
, callback: Callback
<
string
>
): void
on(type:
'formUninstall'
, callback: Callback
<
string
>
): void
订阅卡片卸载事件。使用callback异步回调。
...
...
@@ -1154,7 +1154,7 @@ on(type: "formUninstall", callback: Callback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| type | string | 是 | 填写
"formUninstall"
,表示卡片卸载事件。 |
| type | string | 是 | 填写
'formUninstall'
,表示卡片卸载事件。 |
| callback | Callback
<
string
>
| 是 | 回调函数。返回卡片标识。 |
**示例:**
...
...
@@ -1163,12 +1163,12 @@ on(type: "formUninstall", callback: Callback<string>): void
let
callback
=
function
(
formId
)
{
console
.
log
(
'
formHost on formUninstall, formId:
'
+
formId
);
}
formHost
.
on
(
"
formUninstall
"
,
callback
);
formHost
.
on
(
'
formUninstall
'
,
callback
);
```
## off(
"formUninstall"
)
## off(
'formUninstall'
)
off(type:
"formUninstall"
, callback?: Callback
<
string
>
): void
off(type:
'formUninstall'
, callback?: Callback
<
string
>
): void
取消订阅卡片卸载事件。使用callback异步回调。
...
...
@@ -1178,7 +1178,7 @@ off(type: "formUninstall", callback?: Callback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| type | string | 是 | 填写
"formUninstall"
,表示卡片卸载事件。 |
| type | string | 是 | 填写
'formUninstall'
,表示卡片卸载事件。 |
| callback | Callback
<
string
>
| 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。 |
**示例:**
...
...
@@ -1187,7 +1187,7 @@ off(type: "formUninstall", callback?: Callback<string>): void
let
callback
=
function
(
formId
)
{
console
.
log
(
'
formHost on formUninstall, formId:
'
+
formId
);
}
formHost
.
off
(
"
formUninstall
"
,
callback
);
formHost
.
off
(
'
formUninstall
'
,
callback
);
```
## notifyFormsVisible
...
...
@@ -1218,7 +1218,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsVisible
(
formIds
,
true
,
(
error
,
data
)
=>
{
if
(
error
)
{
...
...
@@ -1263,7 +1263,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsVisible
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsVisible success
'
);
...
...
@@ -1303,7 +1303,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
,
(
error
,
data
)
=>
{
if
(
error
)
{
...
...
@@ -1348,7 +1348,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean):
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsEnableUpdate success
'
);
...
...
@@ -1388,8 +1388,8 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>)
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
deviceId
=
"
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
"
;
var
formId
=
'
12400633174999288
'
;
var
deviceId
=
'
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
'
;
try
{
formHost
.
shareForm
(
formId
,
deviceId
,
(
error
,
data
)
=>
{
if
(
error
)
{
...
...
@@ -1434,8 +1434,8 @@ shareForm(formId: string, deviceId: string): Promise<void>
**参数:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
deviceId
=
"
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
"
;
var
formId
=
'
12400633174999288
'
;
var
deviceId
=
'
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
'
;
try
{
formHost
.
shareForm
(
formId
,
deviceId
).
then
(()
=>
{
console
.
log
(
'
formHost shareForm success
'
);
...
...
@@ -1463,7 +1463,7 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb
| deviceId | string | 是 | 远程设备标识。 |
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsPrivacyProtected
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost shareForm success
'
);
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md
浏览文件 @
b2011405
...
...
@@ -37,7 +37,7 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
try
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
,
(
error
,
data
)
=>
{
if
(
error
)
{
...
...
@@ -47,7 +47,7 @@ try {
}
});
}
catch
(
error
)
{
console
.
log
(
"
error
"
+
JSON
.
stringify
(
error
))
console
.
log
(
'
error
'
+
JSON
.
stringify
(
error
))
}
```
...
...
@@ -82,7 +82,7 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void>
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
try
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
).
then
(()
=>
{
console
.
log
(
'
formProvider setFormNextRefreshTime success
'
);
...
...
@@ -121,9 +121,9 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
```
ts
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
try
{
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
formProvider
.
updateForm
(
formId
,
obj
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formProvider updateForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -168,8 +168,8 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
```
ts
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
var
formId
=
"
12400633174999288
"
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
var
formId
=
'
12400633174999288
'
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
try
{
formProvider
.
updateForm
(
formId
,
obj
).
then
(()
=>
{
console
.
log
(
'
formProvider updateForm success
'
);
...
...
@@ -246,7 +246,7 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array&l
import
formInfo
from
'
@ohos.application.formInfo
'
;
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
"
entry
"
moduleName
:
'
entry
'
};
try
{
formProvider
.
getFormsInfo
(
filter
,
(
error
,
data
)
=>
{
...
...
@@ -294,7 +294,7 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.For
import
formInfo
from
'
@ohos.application.formInfo
'
;
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
"
entry
"
moduleName
:
'
entry
'
};
try
{
formProvider
.
getFormsInfo
(
filter
).
then
((
data
)
=>
{
...
...
@@ -321,7 +321,7 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData,
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
"ohos.extra.param.key.form_dimension"
<br>
"ohos.extra.param.key.form_name"
<br>
"ohos.extra.param.key.module_name"
|
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
'ohos.extra.param.key.form_dimension'
<br>
'ohos.extra.param.key.form_name'
<br>
'ohos.extra.param.key.module_name'
|
| formBindingData.FormBindingData |
[
FormBindingData
](
js-apis-app-form-formBindingData.md#formbindingdata
)
| 是 | 创建卡片的数据。 |
| callback | AsyncCallback
<
string
>
| 是 | 回调函数。返回卡片标识。 |
...
...
@@ -337,15 +337,15 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData,
```
ts
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
var
want
=
{
abilityName
:
"
FormAbility
"
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.module_name
'
:
'
entry
'
}
};
try
{
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
formProvider
.
requestPublishForm
(
want
,
obj
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formProvider requestPublishForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -372,7 +372,7 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
"ohos.extra.param.key.form_dimension"
<br>
"ohos.extra.param.key.form_name"
<br>
"ohos.extra.param.key.module_name"
|
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
'ohos.extra.param.key.form_dimension'
<br>
'ohos.extra.param.key.form_name'
<br>
'ohos.extra.param.key.module_name'
|
| callback | AsyncCallback
<
string
>
| 是 | 回调函数。返回卡片标识。 |
**错误码:**
...
...
@@ -386,11 +386,11 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void
```
ts
var
want
=
{
abilityName
:
"
FormAbility
"
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.module_name
'
:
'
entry
'
}
};
try
{
...
...
@@ -421,7 +421,7 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
"ohos.extra.param.key.form_dimension"
<br>
"ohos.extra.param.key.form_name"
<br>
"ohos.extra.param.key.module_name"
|
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
'ohos.extra.param.key.form_dimension'
<br>
'ohos.extra.param.key.form_name'
<br>
'ohos.extra.param.key.module_name'
|
| formBindingData.FormBindingData |
[
FormBindingData
](
js-apis-app-form-formBindingData.md#formbindingdata
)
| 否 | 创建卡片的数据。 |
**返回值:**
...
...
@@ -441,11 +441,11 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
```
ts
var
want
=
{
abilityName
:
"
FormAbility
"
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.module_name
'
:
'
entry
'
}
};
try
{
...
...
@@ -485,11 +485,11 @@ try {
}
else
{
if
(
isSupported
)
{
var
want
=
{
abilityName
:
"
FormAbility
"
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.module_name
'
:
'
entry
'
}
};
try
{
...
...
@@ -535,11 +535,11 @@ try {
formProvider
.
isRequestPublishFormSupported
().
then
((
isSupported
)
=>
{
if
(
isSupported
)
{
var
want
=
{
abilityName
:
"
FormAbility
"
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.module_name
'
:
'
entry
'
}
};
try
{
...
...
zh-cn/application-dev/reference/apis/js-apis-application-ability.md
浏览文件 @
b2011405
...
...
@@ -204,11 +204,11 @@ onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
**示例:**
```
ts
import
AbilityConstant
from
"
@ohos.application.AbilityConstant
"
import
AbilityConstant
from
'
@ohos.application.AbilityConstant
'
;
class
myAbility
extends
Ability
{
onContinue
(
wantParams
)
{
console
.
log
(
'
onContinue
'
);
wantParams
[
"
myData
"
]
=
"
my1234567
"
;
wantParams
[
'
myData
'
]
=
'
my1234567
'
;
return
AbilityConstant
.
OnContinueResult
.
AGREE
;
}
}
...
...
@@ -285,7 +285,7 @@ dump(params: Array\<string>): Array\<string>;
class
myAbility
extends
Ability
{
dump
(
params
)
{
console
.
log
(
'
dump, params:
'
+
JSON
.
stringify
(
params
));
return
[
"
params
"
]
return
[
'
params
'
]
}
}
```
...
...
@@ -338,12 +338,12 @@ onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any})
**示例:**
```
ts
import
AbilityConstant
from
'
@ohos.application.AbilityConstant
'
import
AbilityConstant
from
'
@ohos.application.AbilityConstant
'
;
class
myAbility
extends
Ability
{
onSaveState
(
reason
,
wantParam
)
{
console
.
log
(
'
onSaveState
'
);
wantParam
[
"
myData
"
]
=
"
my1234567
"
;
wantParam
[
'
myData
'
]
=
'
my1234567
'
;
return
AbilityConstant
.
OnSaveResult
.
RECOVERY_AGREE
;
}
}
...
...
@@ -391,8 +391,8 @@ call(method: string, data: rpc.Sequenceable): Promise<void>;
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
class
MyMessageAble
{
// 自定义的Sequenceable数据结构
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -416,12 +416,12 @@ call(method: string, data: rpc.Sequenceable): Promise<void>;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
let
msg
=
new
MyMessageAble
(
"
msg
"
,
"
world
"
);
// 参考Sequenceable数据定义
let
msg
=
new
MyMessageAble
(
'
msg
'
,
'
world
'
);
// 参考Sequenceable数据定义
caller
.
call
(
method
,
msg
)
.
then
(()
=>
{
console
.
log
(
'
Caller call() called
'
);
...
...
@@ -475,8 +475,8 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
class
MyMessageAble
{
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -500,16 +500,16 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
let
msg
=
new
MyMessageAble
(
1
,
"
world
"
);
let
msg
=
new
MyMessageAble
(
1
,
'
world
'
);
caller
.
callWithResult
(
method
,
msg
)
.
then
((
data
)
=>
{
console
.
log
(
'
Caller callWithResult() called
'
);
let
retmsg
=
new
MyMessageAble
(
0
,
""
);
let
retmsg
=
new
MyMessageAble
(
0
,
''
);
data
.
readSequenceable
(
retmsg
);
})
.
catch
((
callErr
)
=>
{
...
...
@@ -550,9 +550,9 @@ release(): void;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
...
...
@@ -591,9 +591,9 @@ release(): void;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
...
...
@@ -645,8 +645,8 @@ on(method: string, callback: CalleeCallBack): void;
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
class
MyMessageAble
{
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -668,9 +668,9 @@ on(method: string, callback: CalleeCallBack): void;
let
method
=
'
call_Function
'
;
function
funcCallBack
(
pdata
)
{
console
.
log
(
'
Callee funcCallBack is called
'
+
pdata
);
let
msg
=
new
MyMessageAble
(
"
test
"
,
""
);
let
msg
=
new
MyMessageAble
(
'
test
'
,
''
);
pdata
.
readSequenceable
(
msg
);
return
new
MyMessageAble
(
"
test1
"
,
"
Callee test
"
);
return
new
MyMessageAble
(
'
test1
'
,
'
Callee test
'
);
}
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
浏览文件 @
b2011405
...
...
@@ -66,7 +66,7 @@ getArguments(): AbilityDelegatorArgs
```
ts
let
args
=
AbilityDelegatorRegistry
.
getArguments
();
console
.
info
(
"
getArguments bundleName:
"
+
args
.
bundleName
);
console
.
info
(
"
getArguments testCaseNames:
"
+
args
.
testCaseNames
);
console
.
info
(
"
getArguments testRunnerClassName:
"
+
args
.
testRunnerClassName
);
console
.
info
(
'
getArguments bundleName:
'
+
args
.
bundleName
);
console
.
info
(
'
getArguments testCaseNames:
'
+
args
.
testCaseNames
);
console
.
info
(
'
getArguments testRunnerClassName:
'
+
args
.
testRunnerClassName
);
```
zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
浏览文件 @
b2011405
...
...
@@ -11,7 +11,7 @@ AbilityLifecycleCallback模块提供应用上下文ApplicationContext的生命
## 导入模块
```
ts
import
AbilityLifecycleCallback
from
"
@ohos.application.AbilityLifecycleCallback
"
;
import
AbilityLifecycleCallback
from
'
@ohos.application.AbilityLifecycleCallback
'
;
```
...
...
@@ -157,56 +157,56 @@ onAbilityContinue(ability: Ability): void;
```
ts
import
AbilityStage
from
"
@ohos.application.AbilityStage
"
;
import
AbilityStage
from
'
@ohos.application.AbilityStage
'
;
let
lifecycleid
;
export
default
class
MyAbilityStage
extends
AbilityStage
{
onCreate
()
{
console
.
log
(
"
MyAbilityStage onCreate
"
)
console
.
log
(
'
MyAbilityStage onCreate
'
)
let
AbilityLifecycleCallback
=
{
onAbilityCreate
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityCreate ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
AbilityLifecycleCallback onAbilityCreate ability:
'
+
JSON
.
stringify
(
ability
));
},
onWindowStageCreate
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageCreate ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
"
AbilityLifecycleCallback onWindowStageCreate windowStage:
"
+
JSON
.
stringify
(
windowStage
));
console
.
log
(
'
AbilityLifecycleCallback onWindowStageCreate ability:
'
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
AbilityLifecycleCallback onWindowStageCreate windowStage:
'
+
JSON
.
stringify
(
windowStage
));
},
onWindowStageActive
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageActive ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
"
AbilityLifecycleCallback onWindowStageActive windowStage:
"
+
JSON
.
stringify
(
windowStage
));
console
.
log
(
'
AbilityLifecycleCallback onWindowStageActive ability:
'
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
AbilityLifecycleCallback onWindowStageActive windowStage:
'
+
JSON
.
stringify
(
windowStage
));
},
onWindowStageInactive
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageInactive ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
"
AbilityLifecycleCallback onWindowStageInactive windowStage:
"
+
JSON
.
stringify
(
windowStage
));
console
.
log
(
'
AbilityLifecycleCallback onWindowStageInactive ability:
'
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
AbilityLifecycleCallback onWindowStageInactive windowStage:
'
+
JSON
.
stringify
(
windowStage
));
},
onWindowStageDestroy
(
ability
,
windowStage
){
console
.
log
(
"
AbilityLifecycleCallback onWindowStageDestroy ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
"
AbilityLifecycleCallback onWindowStageDestroy windowStage:
"
+
JSON
.
stringify
(
windowStage
));
console
.
log
(
'
AbilityLifecycleCallback onWindowStageDestroy ability:
'
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
AbilityLifecycleCallback onWindowStageDestroy windowStage:
'
+
JSON
.
stringify
(
windowStage
));
},
onAbilityDestroy
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityDestroy ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
AbilityLifecycleCallback onAbilityDestroy ability:
'
+
JSON
.
stringify
(
ability
));
},
onAbilityForeground
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityForeground ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
AbilityLifecycleCallback onAbilityForeground ability:
'
+
JSON
.
stringify
(
ability
));
},
onAbilityBackground
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityBackground ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
AbilityLifecycleCallback onAbilityBackground ability:
'
+
JSON
.
stringify
(
ability
));
},
onAbilityContinue
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityContinue ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
AbilityLifecycleCallback onAbilityContinue ability:
'
+
JSON
.
stringify
(
ability
));
}
}
// 1.通过context属性获取applicationContext
let
applicationContext
=
this
.
context
.
getApplicationContext
();
// 2.通过applicationContext注册监听应用内生命周期
lifecycleid
=
applicationContext
.
registerAbilityLifecycleCallback
(
AbilityLifecycleCallback
);
console
.
log
(
"
registerAbilityLifecycleCallback number:
"
+
JSON
.
stringify
(
lifecycleid
));
console
.
log
(
'
registerAbilityLifecycleCallback number:
'
+
JSON
.
stringify
(
lifecycleid
));
}
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
unregisterAbilityLifecycleCallback
(
lifecycleid
,
(
error
,
data
)
=>
{
console
.
log
(
"
unregisterAbilityLifecycleCallback success, err:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
unregisterAbilityLifecycleCallback success, err:
'
+
JSON
.
stringify
(
error
));
});
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md
浏览文件 @
b2011405
...
...
@@ -10,7 +10,7 @@ AbilityManager模块提供对Ability相关信息和状态信息进行获取、
## 导入模块
```
ts
import
AbilityManager
from
'
@ohos.application.abilityManager
'
import
AbilityManager
from
'
@ohos.application.abilityManager
'
;
```
## AbilityState
...
...
@@ -53,7 +53,7 @@ import abilitymanager from '@ohos.application.abilityManager';
let
config
=
{
language
:
'
chinese
'
}
}
;
abilitymanager
.
updateConfiguration
(
config
,
()
=>
{
console
.
log
(
'
------------ updateConfiguration -----------
'
);
...
...
@@ -89,7 +89,7 @@ import abilitymanager from '@ohos.application.abilityManager';
let
config
=
{
language
:
'
chinese
'
}
}
;
abilitymanager
.
updateConfiguration
(
config
).
then
(()
=>
{
console
.
log
(
'
updateConfiguration success
'
);
...
...
@@ -146,8 +146,8 @@ getAbilityRunningInfos(): Promise\<Array\<AbilityRunningInfo>>
import
abilitymanager
from
'
@ohos.application.abilityManager
'
;
abilitymanager
.
getAbilityRunningInfos
().
then
((
data
)
=>
{
console
.
log
(
"
getAbilityRunningInfos data:
"
+
JSON
.
stringify
(
data
))
console
.
log
(
"
getAbilityRunningInfos data:
"
+
JSON
.
stringify
(
data
))
;
}).
catch
((
err
)
=>
{
console
.
log
(
"
getAbilityRunningInfos err:
"
+
err
)
console
.
log
(
"
getAbilityRunningInfos err:
"
+
err
)
;
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md
浏览文件 @
b2011405
...
...
@@ -9,7 +9,7 @@
## 导入模块
```
ts
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
;
```
## 属性
...
...
@@ -137,7 +137,7 @@ onAccessibilityEvent(event: AccessibilityEvent): void;
class
MyAccessibilityExtensionAbility
extends
AccessibilityExtensionAbility
{
onAccessibilityEvent
(
event
)
{
console
.
log
(
'
AxExtensionAbility onAccessibilityEvent
'
);
if
(
event
.
eventType
==
'
click
'
)
{
if
(
event
.
eventType
==
=
'
click
'
)
{
console
.
log
(
'
AxExtensionAbility onAccessibilityEvent: click
'
);
}
}
...
...
@@ -164,7 +164,7 @@ onKeyEvent(keyEvent: KeyEvent): boolean;
class
MyAccessibilityExtensionAbility
extends
AccessibilityExtensionAbility
{
onKeyEvent
(
keyEvent
)
{
console
.
log
(
'
AxExtensionAbility onKeyEvent
'
);
if
(
keyEvent
.
keyCode
==
22
)
{
if
(
keyEvent
.
keyCode
==
=
22
)
{
console
.
log
(
'
AxExtensionAbility onKeyEvent: intercept 22
'
);
return
true
;
}
...
...
zh-cn/application-dev/reference/apis/js-apis-application-appManager.md
浏览文件 @
b2011405
...
...
@@ -32,7 +32,7 @@ static isRunningInStabilityTest(callback: AsyncCallback<boolean>): void
import
app
from
'
@ohos.application.appManager
'
;
app
.
isRunningInStabilityTest
((
err
,
flag
)
=>
{
console
.
log
(
'
startAbility result:
'
+
JSON
.
stringify
(
err
));
})
})
;
```
...
...
@@ -106,7 +106,7 @@ isRamConstrainedDevice(callback: AsyncCallback\<boolean>): void;
app
.
isRamConstrainedDevice
((
err
,
data
)
=>
{
console
.
log
(
'
startAbility result failed:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
startAbility result success:
'
+
JSON
.
stringify
(
data
));
})
})
;
```
## appManager.getAppMemorySize
...
...
@@ -153,7 +153,7 @@ getAppMemorySize(callback: AsyncCallback\<number>): void;
app
.
getAppMemorySize
((
err
,
data
)
=>
{
console
.
log
(
'
startAbility result failed :
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
startAbility result success:
'
+
JSON
.
stringify
(
data
));
})
})
;
```
## appManager.getProcessRunningInfos<sup>(deprecated)</sup>
...
...
@@ -207,7 +207,7 @@ getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): vo
app
.
getProcessRunningInfos
((
err
,
data
)
=>
{
console
.
log
(
'
startAbility result failed :
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
startAbility result success:
'
+
JSON
.
stringify
(
data
));
})
})
;
```
## appManager.registerApplicationStateObserver<sup>8+</sup>
...
...
@@ -247,7 +247,7 @@ registerApplicationStateObserver(observer: ApplicationStateObserver): number;
onProcessStateChanged
(
processData
)
{
console
.
log
(
'
------------ onProcessStateChanged -----------
'
,
processData
);
}
}
}
;
const
observerCode
=
app
.
registerApplicationStateObserver
(
applicationStateObserver
);
console
.
log
(
'
-------- observerCode: ---------
'
,
observerCode
);
```
...
...
@@ -290,7 +290,7 @@ registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameL
onProcessStateChanged
(
processData
)
{
console
.
log
(
'
------------ onProcessStateChanged -----------
'
,
processData
);
}
}
}
;
let
bundleNameList
=
[
'
bundleName1
'
,
'
bundleName2
'
];
const
observerCode
=
app
.
registerApplicationStateObserver
(
applicationStateObserver
,
bundleNameList
);
console
.
log
(
'
-------- observerCode: ---------
'
,
observerCode
);
...
...
@@ -362,7 +362,7 @@ unregisterApplicationStateObserver(observerId: number): Promise\<void>;
})
.
catch
((
err
)
=>
{
console
.
log
(
'
----------- unregisterApplicationStateObserver fail ----------
'
,
err
);
})
})
;
```
## appManager.getForegroundApplications<sup>8+</sup>
...
...
@@ -423,7 +423,7 @@ getForegroundApplications(): Promise\<Array\<AppStateData>>;
})
.
catch
((
err
)
=>
{
console
.
log
(
'
--------- getForegroundApplications fail -------
'
,
err
);
})
})
;
```
## appManager.killProcessWithAccount<sup>8+</sup>
...
...
@@ -456,7 +456,7 @@ app.killProcessWithAccount(bundleName, accountId)
})
.
catch
((
err
)
=>
{
console
.
log
(
'
------------ killProcessWithAccount fail ------------
'
,
err
);
})
})
;
```
...
...
@@ -562,7 +562,7 @@ killProcessesByBundleName(bundleName: string): Promise\<void>;
})
.
catch
((
err
)
=>
{
console
.
log
(
'
------------ killProcessesByBundleName fail ------------
'
,
err
);
})
})
;
```
## appManager.clearUpApplicationData<sup>8+</sup>
...
...
@@ -632,5 +632,5 @@ clearUpApplicationData(bundleName: string): Promise\<void>;
})
.
catch
((
err
)
=>
{
console
.
log
(
'
------------ clearUpApplicationData fail ------------
'
,
err
);
})
})
;
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-application-configuration.md
浏览文件 @
b2011405
...
...
@@ -32,7 +32,7 @@ export default class MainAbility extends Ability {
onWindowStageCreate
(
windowStage
:
Window
.
WindowStage
)
{
let
envCallback
=
{
onConfigurationUpdated
(
config
)
{
console
.
info
(
`envCallback onConfigurationUpdated success:
${
JSON
.
stringify
(
config
)}
`
)
console
.
info
(
`envCallback onConfigurationUpdated success:
${
JSON
.
stringify
(
config
)}
`
)
;
let
language
=
config
.
language
;
let
colorMode
=
config
.
colorMode
;
}
...
...
zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
浏览文件 @
b2011405
...
...
@@ -14,7 +14,7 @@
## 导入模块
```
ts
import
DataShareExtensionAbility
from
'
@ohos.application.DataShareExtensionAbility
'
import
DataShareExtensionAbility
from
'
@ohos.application.DataShareExtensionAbility
'
;
```
## uri命名规则
...
...
@@ -65,11 +65,11 @@ DataShare客户端连接DataShareExtensionAbility服务端时,服务端回调
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
TBL_NAME
=
"
TBL00
"
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
...
...
@@ -112,22 +112,22 @@ insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<numbe
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
TBL_NAME
=
"
TBL00
"
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
insert
(
uri
,
valueBucket
,
callback
)
{
if
(
valueBucket
==
null
)
{
if
(
valueBucket
==
=
null
)
{
console
.
info
(
'
invalid valueBuckets
'
);
return
;
}
rdbStore
.
insert
(
TBL_NAME
,
valueBucket
,
function
(
err
,
ret
)
{
console
.
info
(
'
callback ret:
'
+
ret
);
if
(
callback
!=
undefined
)
{
if
(
callback
!=
=
undefined
)
{
callback
(
err
,
ret
);
}
});
...
...
@@ -157,20 +157,20 @@ update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueB
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
TBL_NAME
=
"
TBL00
"
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
update
(
uri
,
predicates
,
valueBucket
,
callback
)
{
if
(
predicates
==
null
||
predicates
==
undefined
)
{
if
(
predicates
==
=
null
||
predicates
=
==
undefined
)
{
return
;
}
rdbStore
.
update
(
TBL_NAME
,
valueBucket
,
predicates
,
function
(
err
,
ret
)
{
if
(
callback
!=
undefined
)
{
if
(
callback
!=
=
undefined
)
{
callback
(
err
,
ret
);
}
});
...
...
@@ -199,20 +199,20 @@ delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callba
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
TBL_NAME
=
"
TBL00
"
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
delete
(
uri
,
predicates
,
callback
)
{
if
(
predicates
==
null
||
predicates
==
undefined
)
{
if
(
predicates
==
=
null
||
predicates
=
==
undefined
)
{
return
;
}
rdbStore
.
delete
(
TBL_NAME
,
predicates
,
function
(
err
,
ret
)
{
if
(
callback
!=
undefined
)
{
if
(
callback
!=
=
undefined
)
{
callback
(
err
,
ret
);
}
});
...
...
@@ -242,23 +242,23 @@ query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
TBL_NAME
=
"
TBL00
"
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
query
(
uri
,
predicates
,
columns
,
callback
)
{
if
(
predicates
==
null
||
predicates
==
undefined
)
{
if
(
predicates
==
=
null
||
predicates
=
==
undefined
)
{
return
;
}
rdbStore
.
query
(
TBL_NAME
,
predicates
,
columns
,
function
(
err
,
resultSet
)
{
if
(
resultSet
!=
undefined
)
{
if
(
resultSet
!=
=
undefined
)
{
console
.
info
(
'
resultSet.rowCount:
'
+
resultSet
.
rowCount
);
}
if
(
callback
!=
undefined
)
{
if
(
callback
!=
=
undefined
)
{
callback
(
err
,
resultSet
);
}
});
...
...
@@ -287,23 +287,23 @@ batchInsert?(uri: string, valueBuckets: Array<ValuesBucket>, callback: Asy
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
TBL_NAME
=
"
TBL00
"
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
batchInsert
(
uri
,
valueBuckets
,
callback
)
{
if
(
valueBuckets
==
null
||
valueBuckets
.
length
==
undefined
)
{
if
(
valueBuckets
==
=
null
||
valueBuckets
.
length
=
==
undefined
)
{
console
.
info
(
'
invalid valueBuckets
'
);
return
;
}
let
resultNum
=
valueBuckets
.
length
let
resultNum
=
valueBuckets
.
length
;
valueBuckets
.
forEach
(
vb
=>
{
rdbStore
.
insert
(
TBL_NAME
,
vb
,
function
(
err
,
ret
)
{
if
(
callback
!=
undefined
)
{
if
(
callback
!=
=
undefined
)
{
callback
(
err
,
resultNum
);
}
});
...
...
@@ -332,8 +332,8 @@ normalizeUri?(uri: string, callback: AsyncCallback<string>): void
```
ts
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
normalizeUri
(
uri
,
callback
)
{
let
err
=
{
"
code
"
:
0
};
let
ret
=
"
normalize+
"
+
uri
;
let
err
=
{
'
code
'
:
0
};
let
ret
=
'
normalize+
'
+
uri
;
callback
(
err
,
ret
);
}
};
...
...
@@ -359,8 +359,8 @@ denormalizeUri?(uri: string, callback: AsyncCallback<string>): void
```
ts
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
denormalizeUri
(
uri
,
callback
)
{
let
err
=
{
"
code
"
:
0
};
let
ret
=
"
denormalize+
"
+
uri
;
let
err
=
{
'
code
'
:
0
};
let
ret
=
'
denormalize+
'
+
uri
;
callback
(
err
,
ret
);
}
};
...
...
zh-cn/application-dev/reference/apis/js-apis-application-environmentCallback.md
浏览文件 @
b2011405
...
...
@@ -11,7 +11,7 @@ EnvironmentCallback模块提供应用上下文ApplicationContext对系统环境
## 导入模块
```
ts
import
EnvironmentCallback
from
"
@ohos.application.EnvironmentCallback
"
;
import
EnvironmentCallback
from
'
@ohos.application.EnvironmentCallback
'
;
```
...
...
@@ -33,29 +33,29 @@ onConfigurationUpdated(config: Configuration): void;
```
ts
import
Ability
from
"
@ohos.application.Ability
"
;
import
Ability
from
'
@ohos.application.Ability
'
;
let
callbackId
;
export
default
class
MyAbility
extends
Ability
{
onCreate
()
{
console
.
log
(
"
MyAbility onCreate
"
)
console
.
log
(
'
MyAbility onCreate
'
);
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
let
EnvironmentCallback
=
{
onConfigurationUpdated
(
config
){
console
.
log
(
"
onConfigurationUpdated config:
"
+
JSON
.
stringify
(
config
));
console
.
log
(
'
onConfigurationUpdated config:
'
+
JSON
.
stringify
(
config
));
},
}
}
;
// 1.获取applicationContext
let
applicationContext
=
globalThis
.
applicationContext
;
// 2.通过applicationContext注册监听应用内生命周期
callbackId
=
applicationContext
.
registerEnvironmentCallback
(
EnvironmentCallback
);
console
.
log
(
"
registerEnvironmentCallback number:
"
+
JSON
.
stringify
(
callbackId
));
console
.
log
(
'
registerEnvironmentCallback number:
'
+
JSON
.
stringify
(
callbackId
));
}
onDestroy
()
{
let
applicationContext
=
globalThis
.
applicationContext
;
applicationContext
.
unregisterEnvironmentCallback
(
callbackId
,
(
error
,
data
)
=>
{
console
.
log
(
"
unregisterEnvironmentCallback success, err:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
unregisterEnvironmentCallback success, err:
'
+
JSON
.
stringify
(
error
));
});
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-application-errorManager.md
浏览文件 @
b2011405
...
...
@@ -30,7 +30,7 @@ registerErrorObserver(observer: ErrorObserver): number;
```
ts
let
observer
=
{
onUnhandledException
(
errorMsg
)
{
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
)
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
)
;
}
}
errorManager
.
registerErrorObserver
(
observer
)
...
...
@@ -95,6 +95,6 @@ errorManager.unregisterErrorObserver(observerId)
})
.
catch
((
err
)
=>
{
console
.
log
(
'
----------- unregisterErrorObserver fail ----------
'
,
err
);
})
})
;
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-application-formBindingData.md
浏览文件 @
b2011405
...
...
@@ -35,7 +35,7 @@ createFormBindingData(obj?: Object | string): FormBindingData
| 参数名 | 类型 | 必填 | 说明 |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| obj | Object
\|
string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以
"formImages"作为标识,内容为图片标识与图片文件描述符的键值对{"formImages": {"key1": fd1, "key2"
: fd2}} |
| obj | Object
\|
string | 否 | js卡片要展示的数据。可以是包含若干键值对的Object或者 json 格式的字符串。其中图片数据以
'formImages'作为标识,内容为图片标识与图片文件描述符的键值对{'formImages': {'key1': fd1, 'key2'
: fd2}} |
**返回值:**
...
...
@@ -52,12 +52,12 @@ import featureAbility from '@ohos.ability.featureAbility';
import
fileio
from
'
@ohos.fileio
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
((
err
,
data
)
=>
{
let
path
=
data
+
"
/xxx.jpg
"
;
let
path
=
data
+
'
/xxx.jpg
'
;
let
fd
=
fileio
.
openSync
(
path
);
let
obj
=
{
"
temperature
"
:
"
21°
"
,
"
formImages
"
:
{
"
image
"
:
fd
}
'
temperature
'
:
'
21°
'
,
'
formImages
'
:
{
'
image
'
:
fd
}
};
let
formBindingDataObj
=
formBindingData
.
createFormBindingData
(
obj
);
})
})
;
```
zh-cn/application-dev/reference/apis/js-apis-application-formHost.md
浏览文件 @
b2011405
...
...
@@ -34,7 +34,7 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost deleteForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -67,7 +67,7 @@ deleteForm(formId: string): Promise<void>
**参数:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost deleteForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -95,7 +95,7 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost releaseForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -124,7 +124,7 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost releaseForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -158,7 +158,7 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost releaseForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -186,7 +186,7 @@ requestForm(formId: string, callback: AsyncCallback<void>): void
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost requestForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -219,7 +219,7 @@ requestForm(formId: string): Promise<void>
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost requestForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -247,7 +247,7 @@ castTempForm(formId: string, callback: AsyncCallback<void>): void
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
castTempForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost castTempForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -280,7 +280,7 @@ castTempForm(formId: string): Promise<void>
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
castTempForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost castTempForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -308,7 +308,7 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void
**示例:**
```
ts
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost notifyVisibleForms, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -341,7 +341,7 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>
**示例:**
```
ts
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyVisibleForms success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -369,7 +369,7 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo
**示例:**
```
ts
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost notifyInvisibleForms, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -402,7 +402,7 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>
**示例:**
```
ts
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyInvisibleForms success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -430,7 +430,7 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void&
**示例:**
```
ts
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost enableFormsUpdate, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -463,7 +463,7 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>
**示例:**
```
ts
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost enableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -491,7 +491,7 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void
**示例:**
```
ts
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost disableFormsUpdate, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -524,7 +524,7 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>
**示例:**
```
ts
var
formId
=
[
"
12400633174999288
"
];
var
formId
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost disableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -549,7 +549,7 @@ isSystemReady(callback: AsyncCallback<void>): void
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
isSystemReady
((
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost isSystemReady, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -574,7 +574,7 @@ isSystemReady(): Promise<void>
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formHost
.
isSystemReady
().
then
(()
=>
{
console
.
log
(
'
formHost isSystemReady success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -656,7 +656,7 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo
**示例:**
```
ts
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
...
...
@@ -686,7 +686,7 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<
**示例:**
```
ts
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
"
entry
"
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
...
...
@@ -721,7 +721,7 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI
**示例:**
```
ts
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
"
entry
"
).
then
((
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
).
then
((
data
)
=>
{
console
.
log
(
'
formHost getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -748,7 +748,7 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost deleteInvalidForms, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -783,7 +783,7 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
).
then
((
data
)
=>
{
console
.
log
(
'
formHost deleteInvalidForms, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -812,13 +812,13 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g
```
ts
var
want
=
{
"
deviceId
"
:
""
,
"
bundleName
"
:
"
ohos.samples.FormApplication
"
,
"
abilityName
"
:
"
FormAbility
"
,
"
parameters
"
:
{
"
ohos.extra.param.key.module_name
"
:
"
entry
"
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.form_dimension
"
:
2
'
deviceId
'
:
''
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
abilityName
'
:
'
FormAbility
'
,
'
parameters
'
:
{
'
ohos.extra.param.key.module_name
'
:
'
entry
'
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.form_dimension
'
:
2
}
};
formHost
.
acquireFormState
(
want
,
(
error
,
data
)
=>
{
...
...
@@ -856,13 +856,13 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
```
ts
var
want
=
{
"
deviceId
"
:
""
,
"
bundleName
"
:
"
ohos.samples.FormApplication
"
,
"
abilityName
"
:
"
FormAbility
"
,
"
parameters
"
:
{
"
ohos.extra.param.key.module_name
"
:
"
entry
"
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.form_dimension
"
:
2
'
deviceId
'
:
''
,
'
bundleName
'
:
'
ohos.samples.FormApplication
'
,
'
abilityName
'
:
'
FormAbility
'
,
'
parameters
'
:
{
'
ohos.extra.param.key.module_name
'
:
'
entry
'
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.form_dimension
'
:
2
}
};
formHost
.
acquireFormState
(
want
).
then
((
data
)
=>
{
...
...
@@ -872,9 +872,9 @@ formHost.acquireFormState(want).then((data) => {
});
```
## on(
"formUninstall"
)
## on(
'formUninstall'
)
on(type:
"formUninstall"
, callback: Callback
<
string
>
): void
on(type:
'formUninstall'
, callback: Callback
<
string
>
): void
订阅卡片卸载事件。使用callback异步回调。
...
...
@@ -884,7 +884,7 @@ on(type: "formUninstall", callback: Callback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| type | string | 是 | 填写
"formUninstall"
,表示卡片卸载事件。 |
| type | string | 是 | 填写
'formUninstall'
,表示卡片卸载事件。 |
| callback | Callback
<
string
>
| 是 | 回调函数。返回卡片标识。 |
**示例:**
...
...
@@ -893,12 +893,12 @@ on(type: "formUninstall", callback: Callback<string>): void
let
callback
=
function
(
formId
)
{
console
.
log
(
'
formHost on formUninstall, formId:
'
+
formId
);
}
formHost
.
on
(
"
formUninstall
"
,
callback
);
formHost
.
on
(
'
formUninstall
'
,
callback
);
```
## off(
"formUninstall"
)
## off(
'formUninstall'
)
off(type:
"formUninstall"
, callback?: Callback
<
string
>
): void
off(type:
'formUninstall'
, callback?: Callback
<
string
>
): void
取消订阅卡片卸载事件。使用callback异步回调。
...
...
@@ -908,7 +908,7 @@ off(type: "formUninstall", callback?: Callback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| type | string | 是 | 填写
"formUninstall"
,表示卡片卸载事件。 |
| type | string | 是 | 填写
'formUninstall'
,表示卡片卸载事件。 |
| callback | Callback
<
string
>
| 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。 |
**示例:**
...
...
@@ -917,7 +917,7 @@ off(type: "formUninstall", callback?: Callback<string>): void
let
callback
=
function
(
formId
)
{
console
.
log
(
'
formHost on formUninstall, formId:
'
+
formId
);
}
formHost
.
off
(
"
formUninstall
"
,
callback
);
formHost
.
off
(
'
formUninstall
'
,
callback
);
```
## notifyFormsVisible
...
...
@@ -941,7 +941,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsVisible
(
formIds
,
true
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost notifyFormsVisible, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -975,7 +975,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsVisible
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsVisible success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -1004,7 +1004,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost notifyFormsEnableUpdate, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -1038,7 +1038,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean):
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsEnableUpdate success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -1066,8 +1066,8 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>)
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
deviceId
=
"
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
"
;
var
formId
=
'
12400633174999288
'
;
var
deviceId
=
'
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
'
;
formHost
.
shareForm
(
formId
,
deviceId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formHost shareForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -1101,8 +1101,8 @@ shareForm(formId: string, deviceId: string): Promise<void>
**参数:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
deviceId
=
"
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
"
;
var
formId
=
'
12400633174999288
'
;
var
deviceId
=
'
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
'
;
formHost
.
shareForm
(
formId
,
deviceId
).
then
(()
=>
{
console
.
log
(
'
formHost shareForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -1126,7 +1126,7 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb
| deviceId | string | 是 | 远程设备标识。 |
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
var
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsPrivacyProtected
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost shareForm success
'
);
}).
catch
((
error
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-application-formProvider.md
浏览文件 @
b2011405
...
...
@@ -31,7 +31,7 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formProvider
.
setFormNextRefreshTime
(
formId
,
5
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formProvider setFormNextRefreshTime, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -63,7 +63,7 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void>
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
var
formId
=
'
12400633174999288
'
;
formProvider
.
setFormNextRefreshTime
(
formId
,
5
).
then
(()
=>
{
console
.
log
(
'
formProvider setFormNextRefreshTime success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -91,8 +91,8 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
```
ts
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
var
formId
=
"
12400633174999288
"
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
var
formId
=
'
12400633174999288
'
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
formProvider
.
updateForm
(
formId
,
obj
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formProvider updateForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -125,8 +125,8 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
```
ts
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
var
formId
=
"
12400633174999288
"
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
var
formId
=
'
12400633174999288
'
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
formProvider
.
updateForm
(
formId
,
obj
).
then
(()
=>
{
console
.
log
(
'
formProvider updateForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -180,7 +180,7 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array&l
import
formInfo
from
'
@ohos.application.formInfo
'
;
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
"
entry
"
moduleName
:
'
entry
'
};
formProvider
.
getFormsInfo
(
filter
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
...
...
@@ -217,7 +217,7 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.For
import
formInfo
from
'
@ohos.application.formInfo
'
;
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
"
entry
"
moduleName
:
'
entry
'
};
formProvider
.
getFormsInfo
(
filter
).
then
((
data
)
=>
{
console
.
log
(
'
formProvider getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
...
...
@@ -240,7 +240,7 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData,
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
"ohos.extra.param.key.form_dimension"
<br>
"ohos.extra.param.key.form_name"
<br>
"ohos.extra.param.key.module_name"
|
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
'ohos.extra.param.key.form_dimension'
<br>
'ohos.extra.param.key.form_name'
<br>
'ohos.extra.param.key.module_name'
|
| formBindingData.FormBindingData |
[
FormBindingData
](
js-apis-application-formBindingData.md#formbindingdata
)
| 是 | 创建卡片的数据。 |
| callback | AsyncCallback
<
string
>
| 是 | 回调函数。返回卡片标识。 |
...
...
@@ -249,14 +249,14 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData,
```
ts
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
var
want
=
{
abilityName
:
"
FormAbility
"
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.module_name
'
:
'
entry
'
}
};
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
formProvider
.
requestPublishForm
(
want
,
obj
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formProvider requestPublishForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -280,18 +280,18 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
"ohos.extra.param.key.form_dimension"
<br>
"ohos.extra.param.key.form_name"
<br>
"ohos.extra.param.key.module_name"
|
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
'ohos.extra.param.key.form_dimension'
<br>
'ohos.extra.param.key.form_name'
<br>
'ohos.extra.param.key.module_name'
|
| callback | AsyncCallback
<
string
>
| 是 | 回调函数。返回卡片标识。 |
**示例:**
```
ts
var
want
=
{
abilityName
:
"
FormAbility
"
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.module_name
'
:
'
entry
'
}
};
formProvider
.
requestPublishForm
(
want
,
(
error
,
data
)
=>
{
...
...
@@ -317,7 +317,7 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
"ohos.extra.param.key.form_dimension"
<br>
"ohos.extra.param.key.form_name"
<br>
"ohos.extra.param.key.module_name"
|
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
'ohos.extra.param.key.form_dimension'
<br>
'ohos.extra.param.key.form_name'
<br>
'ohos.extra.param.key.module_name'
|
| formBindingData.FormBindingData |
[
FormBindingData
](
js-apis-application-formBindingData.md#formbindingdata
)
| 否 | 创建卡片的数据。 |
**返回值:**
...
...
@@ -330,11 +330,11 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
```
ts
var
want
=
{
abilityName
:
"
FormAbility
"
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.module_name
'
:
'
entry
'
}
};
formProvider
.
requestPublishForm
(
want
).
then
((
data
)
=>
{
...
...
@@ -369,11 +369,11 @@ formProvider.isRequestPublishFormSupported((error, isSupported) => {
}
else
{
if
(
isSupported
)
{
var
want
=
{
abilityName
:
"
FormAbility
"
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.module_name
'
:
'
entry
'
}
};
formProvider
.
requestPublishForm
(
want
,
(
error
,
data
)
=>
{
...
...
@@ -410,11 +410,11 @@ isRequestPublishFormSupported(): Promise<boolean>
formProvider
.
isRequestPublishFormSupported
().
then
((
isSupported
)
=>
{
if
(
isSupported
)
{
var
want
=
{
abilityName
:
"
FormAbility
"
,
abilityName
:
'
FormAbility
'
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
'
ohos.extra.param.key.form_dimension
'
:
2
,
'
ohos.extra.param.key.form_name
'
:
'
widget
'
,
'
ohos.extra.param.key.module_name
'
:
'
entry
'
}
};
formProvider
.
requestPublishForm
(
want
).
then
((
data
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md
浏览文件 @
b2011405
...
...
@@ -9,7 +9,7 @@ missionManager模块提供系统任务管理能力,包括对系统任务执行
## 导入模块
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
```
## 权限列表
...
...
@@ -44,15 +44,15 @@ registerMissionListener(listener: MissionListener): number;
```
ts
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)
},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)
}
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);
},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionLabelUpdated-------
'
);
}
};
console
.
log
(
"
registerMissionListener
"
)
console
.
log
(
'
registerMissionListener
'
);
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
```
...
...
@@ -80,20 +80,20 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>
```
ts
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)
},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)
}
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);
},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionLabelUpdated-------
'
);
}
};
console
.
log
(
"
registerMissionListener
"
)
console
.
log
(
'
registerMissionListener
'
);
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
missionManager
.
unregisterMissionListener
(
listenerid
,
(
error
)
=>
{
console
.
log
(
"
unregisterMissionListener
"
);
})
console
.
log
(
'
unregisterMissionListener
'
);
})
;
```
...
...
@@ -125,15 +125,15 @@ unregisterMissionListener(listenerId: number): Promise<void>;
```
ts
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionMovedToFront-------
"
)
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
--------onMissionIconUpdated-------
"
)
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionClosed-------
"
)
},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)
}
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionCreated-------
'
);
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionDestroyed-------
'
);
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionSnapshotChanged-------
'
);
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionMovedToFront-------
'
);
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
'
--------onMissionIconUpdated-------
'
);
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionClosed-------
'
);
},
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
'
--------onMissionLabelUpdated-------
'
);
}
};
console
.
log
(
"
registerMissionListener
"
)
console
.
log
(
'
registerMissionListener
'
);
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
missionManager
.
unregisterMissionListener
(
listenerid
).
catch
(
function
(
err
)
{
...
...
@@ -167,15 +167,15 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
let
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
""
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
console
.
log
(
"
getMissionInfo is called, error.code =
"
+
error
.
code
)
console
.
log
(
"
mission.missionId =
"
+
mission
.
missionId
);
console
.
log
(
"
mission.runningState =
"
+
mission
.
runningState
);
console
.
log
(
"
mission.lockedState =
"
+
mission
.
lockedState
);
console
.
log
(
"
mission.timestamp =
"
+
mission
.
timestamp
);
console
.
log
(
"
mission.label =
"
+
mission
.
label
);
console
.
log
(
"
mission.iconPath =
"
+
mission
.
iconPath
);
let
allMissions
=
missionManager
.
getMissionInfos
(
''
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
''
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
console
.
log
(
'
getMissionInfo is called, error.code =
'
+
error
.
code
)
console
.
log
(
'
mission.missionId =
'
+
mission
.
missionId
);
console
.
log
(
'
mission.runningState =
'
+
mission
.
runningState
);
console
.
log
(
'
mission.lockedState =
'
+
mission
.
lockedState
);
console
.
log
(
'
mission.timestamp =
'
+
mission
.
timestamp
);
console
.
log
(
'
mission.label =
'
+
mission
.
label
);
console
.
log
(
'
mission.iconPath =
'
+
mission
.
iconPath
);
});
```
...
...
@@ -208,9 +208,9 @@ getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>;
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
let
mission
=
missionManager
.
getMissionInfo
(
""
,
10
).
catch
(
function
(
err
){
let
mission
=
missionManager
.
getMissionInfo
(
''
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
```
...
...
@@ -239,13 +239,13 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
})
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
})
;
```
...
...
@@ -277,9 +277,9 @@ getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionIn
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
let
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
let
allMissions
=
missionManager
.
getMissionInfos
(
''
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
```
...
...
@@ -308,19 +308,19 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
missionManager
.
getMissionSnapShot
(
''
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
'
getMissionSnapShot is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
bundleName =
'
+
snapshot
.
ability
.
bundleName
);
})
;
})
;
```
...
...
@@ -352,17 +352,17 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
let
snapshot
=
missionManager
.
getMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
let
snapshot
=
missionManager
.
getMissionSnapShot
(
''
,
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
```
...
...
@@ -390,19 +390,19 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getLowResolutionMissionSnapShot is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
missionManager
.
getLowResolutionMissionSnapShot
(
''
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
'
getLowResolutionMissionSnapShot is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
bundleName =
'
+
snapshot
.
ability
.
bundleName
);
})
;
})
;
```
...
...
@@ -434,17 +434,17 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<M
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
let
snapshot
=
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
let
snapshot
=
missionManager
.
getLowResolutionMissionSnapShot
(
''
,
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
```
...
...
@@ -472,16 +472,16 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void;
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
lockMission is called
"
);
console
.
log
(
'
lockMission is called
'
);
});
});
```
...
...
@@ -514,13 +514,13 @@ lockMission(missionId: number): Promise<void>;
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
catch
(
function
(
err
){
...
...
@@ -551,16 +551,16 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void;
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
unlockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
unlockMission is called
"
);
console
.
log
(
'
unlockMission is called
'
);
});
});
```
...
...
@@ -593,14 +593,14 @@ unlockMission(missionId: number): Promise<void>;
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
catch
(
function
(
err
){
...
...
@@ -634,16 +634,16 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void;
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
clearMission
(
id
).
then
(()
=>
{
console
.
log
(
"
clearMission is called
"
);
console
.
log
(
'
clearMission is called
'
);
});
});
```
...
...
@@ -676,14 +676,14 @@ clearMission(missionId: number): Promise<void>;
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
clearMission
(
id
).
catch
(
function
(
err
){
...
...
@@ -707,10 +707,10 @@ clearAllMissions(callback: AsyncCallback<void>): void;
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
clearAllMissions
().
then
(()
=>
{
console
.
log
(
"
clearAllMissions is called
"
);
console
.
log
(
'
clearAllMissions is called
'
);
});
```
...
...
@@ -736,7 +736,7 @@ clearAllMissions(): Promise<void>;
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
clearAllMissions
().
catch
(
function
(
err
){
console
.
log
(
err
);
});
...
...
@@ -765,16 +765,16 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
console
.
log
(
'
moveMissionToFront is called
'
);
});
});
```
...
...
@@ -803,16 +803,16 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
,{
windowMode
:
101
}).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
console
.
log
(
'
moveMissionToFront is called
'
);
});
});
```
...
...
@@ -846,14 +846,14 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise<void&g
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
let
allMissions
;
missionManager
.
getMissionInfos
(
""
,
10
).
then
(
function
(
res
){
missionManager
.
getMissionInfos
(
''
,
10
).
then
(
function
(
res
){
allMissions
=
res
;
}).
catch
(
function
(
err
){
console
.
log
(
err
);});
console
.
log
(
"
size =
"
+
allMissions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
allMissions
));
console
.
log
(
'
size =
'
+
allMissions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
allMissions
));
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
).
catch
(
function
(
err
){
...
...
zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
浏览文件 @
b2011405
...
...
@@ -9,7 +9,7 @@ StaticSubscriberExtensionAbility模块提供静态订阅者ExtensionAbility的
## 导入模块
```
ts
import
StaticSubscriberExtensionAbility
from
'
@ohos.application.StaticSubscriberExtensionAbility
'
import
StaticSubscriberExtensionAbility
from
'
@ohos.application.StaticSubscriberExtensionAbility
'
;
```
## StaticSubscriberExtensionAbility.onReceiveEvent
...
...
@@ -33,7 +33,7 @@ onReceiveEvent(event: CommonEventData): void;
```
ts
class
MyStaticSubscriberExtensionAbility
extends
StaticSubscriberExtensionAbility
{
onReceiveEvent
(
event
)
{
console
.
log
(
"
onReceiveEvent, event:
"
+
JSON
.
stringify
(
event
))
console
.
log
(
'
onReceiveEvent, event:
'
+
JSON
.
stringify
(
event
));
}
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-application-testRunner.md
浏览文件 @
b2011405
...
...
@@ -11,7 +11,7 @@ TestRunner模块提供了框架测试的能力。包括准备单元测试环境
## 导入模块
```
ts
import
TestRunner
from
'
@ohos.application.testRunner
'
import
TestRunner
from
'
@ohos.application.testRunner
'
;
```
## TestRunner.onPrepare
...
...
@@ -27,7 +27,7 @@ onPrepare(): void
```
ts
export
default
class
UserTestRunner
implements
TestRunner
{
onPrepare
()
{
console
.
log
(
"
Trigger onPrepare
"
)
console
.
log
(
'
Trigger onPrepare
'
);
}
onRun
()
{}
};
...
...
@@ -49,7 +49,7 @@ onRun(): void
export
default
class
UserTestRunner
implements
TestRunner
{
onPrepare
()
{}
onRun
()
{
console
.
log
(
"
Trigger onRun
"
)
console
.
log
(
'
Trigger onRun
'
);
}
};
```
zh-cn/application-dev/reference/apis/js-apis-application-want.md
浏览文件 @
b2011405
...
...
@@ -22,7 +22,7 @@ import Want from '@ohos.application.Want';
| bundleName | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 |
| abilityName | string | 否 | 表示待启动的Ability名称。如果在Want中该字段同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。AbilityName需要在一个应用的范围内保证唯一。 |
| uri | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 |
| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:
"text/xml" 、 "image/
*
"
等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| type | string | 否 | 表示MIME type类型描述,打开文件的类型,主要用于文管打开文件。比如:
'text/xml' 、 'image/
*
'
等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| flags | number | 否 | 表示处理Want的方式。默认传数字,具体参考:
[
flags说明
](
js-apis-ability-wantConstant.md#wantConstant.Flags
)
。 |
| action | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。 |
| parameters | {
[
key: string]: any} | 否 | 表示WantParams描述,由开发者自行决定传入的键值对。默认会携带以下key值:<br>ohos.aafwk.callerPid 表示拉起方的pid。<br>ohos.aafwk.param.callerToken 表示拉起方的token。<br>ohos.aafwk.param.callerUid 表示[bundleInfo
](
js-apis-bundle-BundleInfo.md#bundleinfo-1
)
中的uid,应用包里应用程序的uid。
<br
/>
- component.startup.newRules:表示是否启用新的管控规则。
<br
/>
- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。
<br
/>
- ohos.dlp.params.sandbox:表示dlp文件才会有。 | |
...
...
@@ -35,15 +35,15 @@ import Want from '@ohos.application.Want';
```
ts
var
want
=
{
"
deviceId
"
:
""
,
// deviceId为空表示本设备
"
bundleName
"
:
"
com.extreme.test
"
,
"
abilityName
"
:
"
MainAbility
"
,
"
moduleName
"
:
"
entry
"
// moduleName非必选
'
deviceId
'
:
''
,
// deviceId为空表示本设备
'
bundleName
'
:
'
com.extreme.test
'
,
'
abilityName
'
:
'
MainAbility
'
,
'
moduleName
'
:
'
entry
'
// moduleName非必选
};
this
.
context
.
startAbility
(
want
,
(
error
)
=>
{
// 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability
console
.
log
(
"
error.code =
"
+
error
.
code
)
})
console
.
log
(
'
error.code =
'
+
error
.
code
)
})
;
```
-
通过自定字段传递数据, 以下为当前支持类型。
...
...
@@ -51,84 +51,84 @@ import Want from '@ohos.application.Want';
* 字符串(String)
```ts
let want = {
bundleName:
"com.example.demo"
,
abilityName:
"com.example.demo.MainAbility"
,
bundleName:
'com.example.demo'
,
abilityName:
'com.example.demo.MainAbility'
,
parameters: {
keyForString:
"str"
,
keyForString:
'str'
,
},
}
}
;
```
* 数字(Number)
```ts
let want = {
bundleName:
"com.example.demo"
,
abilityName:
"com.example.demo.MainAbility"
,
bundleName:
'com.example.demo'
,
abilityName:
'com.example.demo.MainAbility'
,
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
}
}
;
```
* 布尔(Boolean)
```ts
let want = {
bundleName:
"com.example.demo"
,
abilityName:
"com.example.demo.MainAbility"
,
bundleName:
'com.example.demo'
,
abilityName:
'com.example.demo.MainAbility'
,
parameters: {
keyForBool: true,
},
}
}
;
```
* 对象(Object)
```ts
let want = {
bundleName:
"com.example.demo"
,
abilityName:
"com.example.demo.MainAbility"
,
bundleName:
'com.example.demo'
,
abilityName:
'com.example.demo.MainAbility'
,
parameters: {
keyForObject: {
keyForObjectString:
"str"
,
keyForObjectString:
'str'
,
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
},
}
}
;
```
* 数组(Array)
```ts
let want = {
bundleName:
"com.example.demo"
,
abilityName:
"com.example.demo.MainAbility"
,
bundleName:
'com.example.demo'
,
abilityName:
'com.example.demo.MainAbility'
,
parameters: {
keyForArrayString: [
"str1", "str2", "str3"
],
keyForArrayString: [
'str1', 'str2', 'str3'
],
keyForArrayInt: [100, 200, 300, 400],
keyForArrayDouble: [0.1, 0.2],
keyForArrayObject: [{obj1:
"aaa"
}, {obj2: 100}],
keyForArrayObject: [{obj1:
'aaa'
}, {obj2: 100}],
},
}
}
;
```
* 文件描述符(FD)
```ts
import fileio from '@ohos.fileio';
var fd;
try {
fd = fileio.openSync(
"/data/storage/el2/base/haps/pic.png"
);
fd = fileio.openSync(
'/data/storage/el2/base/haps/pic.png'
);
} catch(e) {
console.log(
"openSync fail:"
+ JSON.stringify(e));
console.log(
'openSync fail:'
+ JSON.stringify(e));
}
var want = {
"deviceId": ""
, // deviceId为空表示本设备
"bundleName": "com.extreme.test"
,
"abilityName": "MainAbility"
,
"moduleName": "entry"
, // moduleName非必选
"parameters"
: {
"keyFd":{"type":"FD", "value"
:fd}
'deviceId': ''
, // deviceId为空表示本设备
'bundleName': 'com.extreme.test'
,
'abilityName': 'MainAbility'
,
'moduleName': 'entry'
, // moduleName非必选
'parameters'
: {
'keyFd':{'type':'FD', 'value'
:fd}
}
};
this.context.startAbility(want, (error) => {
// 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability
console.log(
"error.code = "
+ error.code)
})
console.log(
'error.code = '
+ error.code)
})
;
```
<!--no_check-->
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md
浏览文件 @
b2011405
...
...
@@ -14,8 +14,8 @@
```
ts
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
let
connectOptions
=
{
...
...
@@ -28,7 +28,7 @@
onFailed
(
code
)
{
console
.
error
(
'
onFailed code:
'
+
code
);
}
}
}
;
let
connection
=
this
.
context
.
connectAbility
(
want
,
connectOptions
);
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md
浏览文件 @
b2011405
...
...
@@ -11,8 +11,8 @@
使用前根据具体情况引入如下模块
```
ts
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
import
ohos_data_rdb
from
'
@ohos.data.rdb
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
;
import
ohos_data_rdb
from
'
@ohos.data.rdb
'
;
```
## DataAbilityHelper.openFile
...
...
@@ -34,13 +34,13 @@ openFile(uri: string, mode: string, callback: AsyncCallback\<number>): void
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
let
mode
=
"
rwt
"
;
DAHelper
.
openFile
(
"
dataability:///com.example.DataAbility
"
,
mode
,
(
err
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
let
mode
=
'
rwt
'
;
DAHelper
.
openFile
(
'
dataability:///com.example.DataAbility
'
,
mode
,
(
err
)
=>
{
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -68,13 +68,13 @@ openFile(uri: string, mode: string): Promise\<number>
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
let
mode
=
"
rwt
"
;
DAHelper
.
openFile
(
"
dataability:///com.example.DataAbility
"
,
mode
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>openFileCallback=======================>
"
);
let
mode
=
'
rwt
'
;
DAHelper
.
openFile
(
'
dataability:///com.example.DataAbility
'
,
mode
).
then
((
data
)
=>
{
console
.
info
(
'
==========================>openFileCallback=======================>
'
);
});
```
...
...
@@ -97,18 +97,18 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback\<void>): void
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
function
onChangeNotify
()
{
console
.
info
(
"
==========================>onChangeNotify=======================>
"
);
console
.
info
(
'
==========================>onChangeNotify=======================>
'
);
};
helper
.
on
(
"
dataChange
"
,
"
dataability:///com.example.DataAbility
"
,
'
dataChange
'
,
'
dataability:///com.example.DataAbility
'
,
onChangeNotify
)
)
;
```
## DataAbilityHelper.off
...
...
@@ -130,22 +130,22 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback\<void>): void
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
function
onChangeNotify
()
{
console
.
info
(
"
==========================>onChangeNotify=======================>
"
);
console
.
info
(
'
==========================>onChangeNotify=======================>
'
);
};
helper
.
off
(
"
dataChange
"
,
"
dataability:///com.example.DataAbility
"
,
)
'
dataChange
'
,
'
dataability:///com.example.DataAbility
'
,
)
;
helper
.
off
(
"
dataChange
"
,
"
dataability:///com.example.DataAbility
"
,
'
dataChange
'
,
'
dataability:///com.example.DataAbility
'
,
onChangeNotify
)
)
;
```
## DataAbilityHelper.getType
...
...
@@ -166,12 +166,12 @@ getType(uri: string, callback: AsyncCallback\<string>): void
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
DAHelper
.
getType
(
"
dataability:///com.example.DataAbility
"
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
DAHelper
.
getType
(
'
dataability:///com.example.DataAbility
'
,
(
err
,
data
)
=>
{
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -198,12 +198,12 @@ getType(uri: string): Promise\<string>
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
DAHelper
.
getType
(
"
dataability:///com.example.DataAbility
"
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getTypeCallback=======================>
"
);
DAHelper
.
getType
(
'
dataability:///com.example.DataAbility
'
).
then
((
data
)
=>
{
console
.
info
(
'
==========================>getTypeCallback=======================>
'
);
});
```
...
...
@@ -226,13 +226,13 @@ getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array\
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
DAHelper
.
getFileTypes
(
"
dataability:///com.example.DataAbility
"
,
"
image/*
"
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
DAHelper
.
getFileTypes
(
'
dataability:///com.example.DataAbility
'
,
'
image/*
'
,
(
err
,
data
)
=>
{
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -262,13 +262,13 @@ getFileTypes(uri: string, mimeTypeFilter: string): Promise\<Array\<string>>
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
DAHelper
.
getFileTypes
(
"
dataability:///com.example.DataAbility
"
,
"
image/*
"
).
then
((
data
)
=>
{
console
.
info
(
"
===================>getFileTypesCallback================>
"
);
DAHelper
.
getFileTypes
(
'
dataability:///com.example.DataAbility
'
,
'
image/*
'
).
then
((
data
)
=>
{
console
.
info
(
'
===================>getFileTypesCallback================>
'
);
});
```
...
...
@@ -290,12 +290,12 @@ normalizeUri(uri: string, callback: AsyncCallback\<string>): void
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
DAHelper
.
normalizeUri
(
"
dataability:///com.example.DataAbility
"
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
DAHelper
.
normalizeUri
(
'
dataability:///com.example.DataAbility
'
,
(
err
,
data
)
=>
{
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -322,12 +322,12 @@ normalizeUri(uri: string): Promise\<string>
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
DAHelper
.
normalizeUri
(
"
dataability:///com.example.DataAbility
"
,).
then
((
data
)
=>
{
console
.
info
(
"
=================>normalizeUriCallback=======================>
"
);
DAHelper
.
normalizeUri
(
'
dataability:///com.example.DataAbility
'
,).
then
((
data
)
=>
{
console
.
info
(
'
=================>normalizeUriCallback=======================>
'
);
});
```
...
...
@@ -349,12 +349,12 @@ denormalizeUri(uri: string, callback: AsyncCallback\<string>): void
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
DAHelper
.
denormalizeUri
(
"
dataability:///com.example.DataAbility
"
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
DAHelper
.
denormalizeUri
(
'
dataability:///com.example.DataAbility
'
,
(
err
,
data
)
=>
{
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -383,12 +383,12 @@ denormalizeUri(uri: string): Promise\<string>
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
DAHelper
.
denormalizeUri
(
"
dataability:///com.example.DataAbility
"
,).
then
((
data
)
=>
{
console
.
info
(
"
===============>denormalizeUriCallback=======================>
"
);
DAHelper
.
denormalizeUri
(
'
dataability:///com.example.DataAbility
'
,).
then
((
data
)
=>
{
console
.
info
(
'
===============>denormalizeUriCallback=======================>
'
);
});
```
...
...
@@ -410,12 +410,12 @@ notifyChange(uri: string, callback: AsyncCallback\<void>): void
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
helper
.
notifyChange
(
"
dataability:///com.example.DataAbility
"
,
(
err
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
helper
.
notifyChange
(
'
dataability:///com.example.DataAbility
'
,
(
err
)
=>
{
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -442,12 +442,12 @@ notifyChange(uri: string): Promise\<void>
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
DAHelper
.
notifyChange
(
"
dataability:///com.example.DataAbility
"
).
then
(()
=>
{
console
.
info
(
"
================>notifyChangeCallback================>
"
);
DAHelper
.
notifyChange
(
'
dataability:///com.example.DataAbility
'
).
then
(()
=>
{
console
.
info
(
'
================>notifyChangeCallback================>
'
);
});
```
...
...
@@ -470,19 +470,19 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\<num
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
const
valueBucket
=
{
"
name
"
:
"
rose
"
,
"
age
"
:
22
,
"
salary
"
:
200.5
,
"
blobType
"
:
"
u8
"
,
}
DAHelper
.
insert
(
"
dataability:///com.example.DataAbility
"
,
valueBucket
,
'
name
'
:
'
rose
'
,
'
age
'
:
22
,
'
salary
'
:
200.5
,
'
blobType
'
:
'
u8
'
,
}
;
DAHelper
.
insert
(
'
dataability:///com.example.DataAbility
'
,
valueBucket
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -510,18 +510,18 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket): Promise\<number>
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
const
valueBucket
=
{
"
name
"
:
"
rose1
"
,
"
age
"
:
221
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,
}
DAHelper
.
insert
(
"
dataability:///com.example.DataAbility
"
,
valueBucket
).
then
((
data
)
=>
{
console
.
info
(
"
====================>insertCallback=======================>
"
);
'
name
'
:
'
rose1
'
,
'
age
'
:
221
,
'
salary
'
:
20.5
,
'
blobType
'
:
'
u8
'
,
}
;
DAHelper
.
insert
(
'
dataability:///com.example.DataAbility
'
,
valueBucket
).
then
((
data
)
=>
{
console
.
info
(
'
====================>insertCallback=======================>
'
);
});
```
...
...
@@ -544,16 +544,16 @@ batchInsert(uri: string, valuesBuckets: Array\<rdb.ValuesBucket>, callback: Asyn
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
let
cars
=
new
Array
({
"
name
"
:
"
roe11
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,},
{
"
name
"
:
"
roe12
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,},
{
"
name
"
:
"
roe13
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,})
DAHelper
.
batchInsert
(
"
dataability:///com.example.DataAbility
"
,
cars
,
let
cars
=
new
Array
({
'
name
'
:
'
roe11
'
,
'
age
'
:
21
,
'
salary
'
:
20.5
,
'
blobType
'
:
'
u8
'
,},
{
'
name
'
:
'
roe12
'
,
'
age
'
:
21
,
'
salary
'
:
20.5
,
'
blobType
'
:
'
u8
'
,},
{
'
name
'
:
'
roe13
'
,
'
age
'
:
21
,
'
salary
'
:
20.5
,
'
blobType
'
:
'
u8
'
,});
DAHelper
.
batchInsert
(
'
dataability:///com.example.DataAbility
'
,
cars
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -581,15 +581,15 @@ batchInsert(uri: string, valuesBuckets: Array<rdb.ValuesBucket>): Promise\<numbe
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
let
cars
=
new
Array
({
"
name
"
:
"
roe11
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,},
{
"
name
"
:
"
roe12
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,},
{
"
name
"
:
"
roe13
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,})
DAHelper
.
batchInsert
(
"
dataability:///com.example.DataAbility
"
,
cars
).
then
((
data
)
=>
{
console
.
info
(
"
==================>batchInsertCallback=======================>
"
);
let
cars
=
new
Array
({
'
name
'
:
'
roe11
'
,
'
age
'
:
21
,
'
salary
'
:
20.5
,
'
blobType
'
:
'
u8
'
,},
{
'
name
'
:
'
roe12
'
,
'
age
'
:
21
,
'
salary
'
:
20.5
,
'
blobType
'
:
'
u8
'
,},
{
'
name
'
:
'
roe13
'
,
'
age
'
:
21
,
'
salary
'
:
20.5
,
'
blobType
'
:
'
u8
'
,});
DAHelper
.
batchInsert
(
'
dataability:///com.example.DataAbility
'
,
cars
).
then
((
data
)
=>
{
console
.
info
(
'
==================>batchInsertCallback=======================>
'
);
});
```
...
...
@@ -612,15 +612,15 @@ delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: Asy
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
DAHelper
.
delete
(
"
dataability:///com.example.DataAbility
"
,
da
,
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
;
DAHelper
.
delete
(
'
dataability:///com.example.DataAbility
'
,
da
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -648,14 +648,14 @@ delete(uri: string, predicates?: dataAbility.DataAbilityPredicates): Promise\<nu
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
DAHelper
.
delete
(
"
dataability:///com.example.DataAbility
"
,
da
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>deleteCallback=======================>
"
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
;
DAHelper
.
delete
(
'
dataability:///com.example.DataAbility
'
,
da
).
then
((
data
)
=>
{
console
.
info
(
'
==========================>deleteCallback=======================>
'
);
});
```
...
...
@@ -679,20 +679,20 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.Data
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
const
va
=
{
"
name
"
:
"
roe1
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,
}
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
DAHelper
.
update
(
"
dataability:///com.example.DataAbility
"
,
va
,
da
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
'
name
'
:
'
roe1
'
,
'
age
'
:
21
,
'
salary
'
:
20.5
,
'
blobType
'
:
'
u8
'
,
}
;
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
;
DAHelper
.
update
(
'
dataability:///com.example.DataAbility
'
,
va
,
da
,
(
err
,
data
)
=>
{
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -721,20 +721,20 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates?: dataAbility.Dat
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
const
va
=
{
"
name
"
:
"
roe1
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,
}
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
DAHelper
.
update
(
"
dataability:///com.example.DataAbility
"
,
va
,
da
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>updateCallback=======================>
"
);
'
name
'
:
'
roe1
'
,
'
age
'
:
21
,
'
salary
'
:
20.5
,
'
blobType
'
:
'
u8
'
,
}
;
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
;
DAHelper
.
update
(
'
dataability:///com.example.DataAbility
'
,
va
,
da
).
then
((
data
)
=>
{
console
.
info
(
'
==========================>updateCallback=======================>
'
);
});
```
...
...
@@ -758,15 +758,15 @@ query(uri: string, columns: Array\<string>, predicates: dataAbility.DataAbilityP
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
let
cars
=
new
Array
(
"
value1
"
,
"
value2
"
,
"
value3
"
,
"
value4
"
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
DAHelper
.
query
(
"
dataability:///com.example.DataAbility
"
,
cars
,
da
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
let
cars
=
new
Array
(
'
value1
'
,
'
value2
'
,
'
value3
'
,
'
value4
'
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
;
DAHelper
.
query
(
'
dataability:///com.example.DataAbility
'
,
cars
,
da
,
(
err
,
data
)
=>
{
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -797,15 +797,15 @@ query(uri: string, columns?: Array\<string>, predicates?: dataAbility.DataAbilit
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
let
cars
=
new
Array
(
"
value1
"
,
"
value2
"
,
"
value3
"
,
"
value4
"
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
DAHelper
.
query
(
"
dataability:///com.example.DataAbility
"
,
cars
,
da
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>queryCallback=======================>
"
);
let
cars
=
new
Array
(
'
value1
'
,
'
value2
'
,
'
value3
'
,
'
value4
'
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
;
DAHelper
.
query
(
'
dataability:///com.example.DataAbility
'
,
cars
,
da
).
then
((
data
)
=>
{
console
.
info
(
'
==========================>queryCallback=======================>
'
);
});
```
...
...
@@ -821,7 +821,7 @@ call(uri: string, method: string, arg: string, extras: PacMap): Promise\<PacMap>
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | --------------------------------- | ---- | ------------------------------------------------ |
| uri | string | 是 | 指定待处理的DataAbility。例:
"dataability:///com.example.xxx.xxxx"
|
| uri | string | 是 | 指定待处理的DataAbility。例:
'dataability:///com.example.xxx.xxxx'
|
| method | string | 是 | 被调用的方法名。 |
| arg | string | 是 |需传入的参数。 |
| extras |
[
PacMap
](
#pacmap
)
| 是 | 键值对参数。 |
...
...
@@ -838,9 +838,9 @@ call(uri: string, method: string, arg: string, extras: PacMap): Promise\<PacMap>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
);
dataAbilityHelper
.
call
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
,
"
method
"
,
"
arg
"
,
{
"
key1
"
:
"
value1
"
}).
then
((
data
)
=>
{
'
dataability:///com.example.jsapidemo.UserDataAbility
'
);
dataAbilityHelper
.
call
(
'
dataability:///com.example.jsapidemo.UserDataAbility
'
,
'
method
'
,
'
arg
'
,
{
'
key1
'
:
'
value1
'
}).
then
((
data
)
=>
{
console
.
info
(
'
Operation succeeded:
'
+
data
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
error
);
...
...
@@ -859,7 +859,7 @@ call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCa
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | --------------------------------- | ---- | ------------------------------------------------ |
| uri | string | 是 | 指定待处理的DataAbility。例:
"dataability:///com.example.xxx.xxxx"
|
| uri | string | 是 | 指定待处理的DataAbility。例:
'dataability:///com.example.xxx.xxxx'
|
| method | string | 是 | 被调用的方法名。 |
| arg | string | 是 |需传入的参数。 |
| extras |
[
PacMap
](
#pacmap
)
| 是 | 键值对参数。 |
...
...
@@ -871,9 +871,9 @@ call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCa
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
);
dataAbilityHelper
.
call
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
,
"
method
"
,
"
arg
"
,
{
"
key1
"
:
"
value1
"
},
(
err
,
data
)
=>
{
'
dataability:///com.example.jsapidemo.UserDataAbility
'
);
dataAbilityHelper
.
call
(
'
dataability:///com.example.jsapidemo.UserDataAbility
'
,
'
method
'
,
'
arg
'
,
{
'
key1
'
:
'
value1
'
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
err
);
return
;
...
...
@@ -894,7 +894,7 @@ executeBatch(uri: string, operations: Array\<DataAbilityOperation>, callback: As
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | --------------------------------- | ---- | ------------------------------------------------ |
| uri | string | 是 | 指定待处理的DataAbility。例:
"dataability:///com.example.xxx.xxxx"
。|
| uri | string | 是 | 指定待处理的DataAbility。例:
'dataability:///com.example.xxx.xxxx'
。|
| operations | Array
\<
[
DataAbilityOperation
](
js-apis-inner-ability-dataAbilityOperation.md
)
> | 是 | 指示数据操作列表,其中可以包含对数据库的多个操作。 |
| callback | AsyncCallback
\<
Array
\<
[
DataAbilityResult
](
js-apis-inner-ability-dataAbilityResult.md
)
>> | 是 |在数组 DataAbilityResult中返回每个操作的结果。 |
...
...
@@ -906,8 +906,8 @@ import featureAbility from '@ohos.ability.featureAbility';
// 根据DataAbilityOperation列表选择要对数据库做的操作
let
op
=
new
Array
();
let
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
);
dataAbilityHelper
.
executeBatch
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
,
'
dataability:///com.example.jsapidemo.UserDataAbility
'
);
dataAbilityHelper
.
executeBatch
(
'
dataability:///com.example.jsapidemo.UserDataAbility
'
,
op
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
err
);
...
...
@@ -929,7 +929,7 @@ executeBatch(uri: string, operations: Array\<DataAbilityOperation>): Promise\<Ar
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | -------------------------------| ---- | ------------------------------------------------ |
| uri | string | 是 | 指定待处理的DataAbility。例:
"dataability:///com.example.xxx.xxxx"
。|
| uri | string | 是 | 指定待处理的DataAbility。例:
'dataability:///com.example.xxx.xxxx'
。|
| operations | Array
\<
[
DataAbilityOperation
](
js-apis-inner-ability-dataAbilityOperation.md
)
> | 是 | 指示数据操作列表,其中可以包含对数据库的多个操作。 |
**返回值:**
...
...
@@ -946,8 +946,8 @@ import featureAbility from '@ohos.ability.featureAbility';
// 根据DataAbilityOperation列表选择要对数据库做的操作
let
op
=
new
Array
();
let
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
);
dataAbilityHelper
.
executeBatch
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
,
'
dataability:///com.example.jsapidemo.UserDataAbility
'
);
dataAbilityHelper
.
executeBatch
(
'
dataability:///com.example.jsapidemo.UserDataAbility
'
,
op
).
then
((
data
)
=>
{
console
.
info
(
'
Operation succeeded:
'
+
data
);
}).
catch
((
error
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md
浏览文件 @
b2011405
...
...
@@ -11,15 +11,15 @@
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uri? | string | 否 | 指定待处理的DataAbility。例:
"dataability:///com.example.xxx.xxxx"
。 |
| uri? | string | 否 | 指定待处理的DataAbility。例:
'dataability:///com.example.xxx.xxxx'
。 |
| count? | number | 否 | 指示受操作影响的行数。 |
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.TestDataAbility
"
);
let
dataAbilityUri
=
(
'
dataability:///com.example.myapplication.TestDataAbility
'
);
let
DAHelper
;
try
{
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
dataAbilityUri
);
...
...
@@ -33,9 +33,9 @@ try {
}
let
valueBucket
=
{
"
name
"
:
"
DataAbilityHelperTest
"
,
"
age
"
:
24
,
"
salary
"
:
2024.20
,
'
name
'
:
'
DataAbilityHelperTest
'
,
'
age
'
:
24
,
'
salary
'
:
2024.20
,
};
let
operations
=
[
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md
浏览文件 @
b2011405
...
...
@@ -16,29 +16,29 @@
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
Want
=
{
bundleName
:
"
com.example.abilityStartSettingApp2
"
,
abilityName
:
"
com.example.abilityStartSettingApp.MainAbility
"
,
}
bundleName
:
'
com.example.abilityStartSettingApp2
'
,
abilityName
:
'
com.example.abilityStartSettingApp.MainAbility
'
,
}
;
let
abilityStartSetting
=
{
[
featureAbility
.
AbilityStartSetting
.
BOUNDS_KEY
]
:
[
100
,
200
,
300
,
400
],
[
featureAbility
.
AbilityStartSetting
.
WINDOW_MODE_KEY
]
:
featureAbility
.
AbilityWindowConfiguration
.
WINDOW_MODE_UNDEFINED
,
[
featureAbility
.
AbilityStartSetting
.
DISPLAY_ID_KEY
]
:
1
,
}
}
;
let
startAbilityParameter
=
{
want
:
Want
,
abilityStartSetting
:
abilityStartSetting
}
}
;
featureAbility
.
startAbility
(
startAbilityParameter
,
(
err
,
data
)
=>
{
console
.
log
(
'
errCode :
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
data :
'
+
JSON
.
stringify
(
data
));
}
catch
(
error
)
{
console
.
log
(
"
startAbility error:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
startAbility error:
'
+
JSON
.
stringify
(
error
));
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-ability-want.md
浏览文件 @
b2011405
...
...
@@ -14,7 +14,7 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传
| bundleName | string | 否 | 表示包名。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 |
| abilityName | string | 否 | 表示待启动的Ability名称。如果在Want中该字段同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。AbilityName需要在一个应用的范围内保证唯一。 |
| uri | string | 否 | 表示Uri。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 |
| type | string | 否 | 表示MIME type类型,打开文件的类型,主要用于文管打开文件。比如:
"text/xml" 、 "image/
*
"
等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| type | string | 否 | 表示MIME type类型,打开文件的类型,主要用于文管打开文件。比如:
'text/xml' 、 'image/
*
'
等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 |
| flags | number | 否 | 表示处理Want的方式。默认传数字,具体参考:
[
flags说明
](
js-apis-ability-wantConstant.md#wantConstant.Flags
)
。 |
| action | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。 |
| parameters | {
[
key: string]: any} | 否 | 表示WantParams,由开发者自行决定传入的键值对。默认会携带以下key值:<br>ohos.aafwk.callerPid 表示拉起方的pid。<br>ohos.aafwk.param.callerToken 表示拉起方的token。<br>ohos.aafwk.param.callerUid 表示[bundleInfo
](
js-apis-bundle-BundleInfo.md#bundleinfo-1
)
中的uid,应用包里应用程序的uid。
<br
/>
- component.startup.newRules:表示是否启用新的管控规则。
<br
/>
- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。
<br
/>
- ohos.dlp.params.sandbox:表示dlp文件才会有。 | |
...
...
@@ -27,42 +27,42 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传
```
ts
let
want
=
{
"
deviceId
"
:
""
,
// deviceId为空表示本设备
"
bundleName
"
:
"
com.extreme.test
"
,
"
abilityName
"
:
"
MainAbility
"
,
"
moduleName
"
:
"
entry
"
// moduleName非必选
'
deviceId
'
:
''
,
// deviceId为空表示本设备
'
bundleName
'
:
'
com.extreme.test
'
,
'
abilityName
'
:
'
MainAbility
'
,
'
moduleName
'
:
'
entry
'
// moduleName非必选
};
this
.
context
.
startAbility
(
want
,
(
error
)
=>
{
// 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability
console
.
log
(
"
error.code =
"
+
error
.
code
)
})
console
.
log
(
'
error.code =
'
+
error
.
code
)
})
;
```
-
传递FD(文件描述符)数据(在UIAbility对象中调用,其中示例中的context为UIAbility的上下文对象)
```
ts
import
fileio
from
'
@ohos.fileio
'
;
import
fileio
from
'
@ohos.fileio
'
;
;
// ...
let
fd
;
try
{
fd
=
fileio
.
openSync
(
"
/data/storage/el2/base/haps/pic.png
"
);
fd
=
fileio
.
openSync
(
'
/data/storage/el2/base/haps/pic.png
'
);
}
catch
(
e
)
{
console
.
log
(
"
openSync fail:
"
+
JSON
.
stringify
(
e
));
console
.
log
(
'
openSync fail:
'
+
JSON
.
stringify
(
e
));
}
let
want
=
{
"
deviceId
"
:
""
,
// deviceId为空表示本设备
"
bundleName
"
:
"
com.extreme.test
"
,
"
abilityName
"
:
"
MainAbility
"
,
"
moduleName
"
:
"
entry
"
,
// moduleName非必选
"
parameters
"
:
{
"
keyFd
"
:{
"
type
"
:
"
FD
"
,
"
value
"
:
fd
}
'
deviceId
'
:
''
,
// deviceId为空表示本设备
'
bundleName
'
:
'
com.extreme.test
'
,
'
abilityName
'
:
'
MainAbility
'
,
'
moduleName
'
:
'
entry
'
,
// moduleName非必选
'
parameters
'
:
{
'
keyFd
'
:{
'
type
'
:
'
FD
'
,
'
value
'
:
fd
}
}
};
this
.
context
.
startAbility
(
want
,
(
error
)
=>
{
// 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability
console
.
log
(
"
error.code =
"
+
error
.
code
)
})
console
.
log
(
'
error.code =
'
+
error
.
code
)
})
;
// ...
```
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-app-context.md
浏览文件 @
b2011405
...
...
@@ -15,7 +15,7 @@ Context对象是在featureAbility中创建实例,并通过featureAbility的[ge
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
().
then
((
data
)
=>
{
console
.
info
(
"
getOrCreateLocalDir data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getOrCreateLocalDir data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -41,7 +41,7 @@ getOrCreateLocalDir(callback: AsyncCallback\<string>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
((
err
,
data
)
=>
{
console
.
info
(
"
getOrCreateLocalDir err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getOrCreateLocalDir err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -69,7 +69,7 @@ getOrCreateLocalDir(): Promise\<string>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
().
then
((
data
)
=>
{
console
.
info
(
"
getOrCreateLocalDir data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getOrCreateLocalDir data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -96,8 +96,8 @@ import featureAbility from '@ohos.ability.featureAbility';
import
bundle
from
'
@ohos.bundle
'
;
let
context
=
featureAbility
.
getContext
();
bundle
.
getBundleInfo
(
'
com.context.test
'
,
1
,
(
err
,
datainfo
)
=>
{
context
.
verifyPermission
(
"
com.example.permission
"
,
{
uid
:
datainfo
.
uid
},
(
err
,
data
)
=>
{
console
.
info
(
"
verifyPermission err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
context
.
verifyPermission
(
'
com.example.permission
'
,
{
uid
:
datainfo
.
uid
},
(
err
,
data
)
=>
{
console
.
info
(
'
verifyPermission err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
});
```
...
...
@@ -124,8 +124,8 @@ verifyPermission(permission: string, callback: AsyncCallback\<number>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
verifyPermission
(
"
com.example.permission
"
,
(
err
,
data
)
=>
{
console
.
info
(
"
verifyPermission err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
context
.
verifyPermission
(
'
com.example.permission
'
,
(
err
,
data
)
=>
{
console
.
info
(
'
verifyPermission err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -157,7 +157,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let
context
=
featureAbility
.
getContext
();
let
Permission
=
{
pid
:
1
};
context
.
verifyPermission
(
'
com.context.permission
'
,
Permission
).
then
((
data
)
=>
{
console
.
info
(
"
verifyPermission data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
verifyPermission data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -185,14 +185,14 @@ requestPermissionsFromUser(permissions: Array\<string>, requestCode: number, res
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
requestPermissionsFromUser
(
[
"
com.example.permission1
"
,
"
com.example.permission2
"
,
"
com.example.permission3
"
,
"
com.example.permission4
"
,
"
com.example.permission5
"
],
[
'
com.example.permission1
'
,
'
com.example.permission2
'
,
'
com.example.permission3
'
,
'
com.example.permission4
'
,
'
com.example.permission5
'
],
1
,
(
err
,
data
)
=>
{
console
.
info
(
"
requestPermissionsFromUser err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
requestPermissionsFromUser err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
}
);
```
...
...
@@ -225,13 +225,13 @@ requestPermissionsFromUser(permissions: Array\<string>, requestCode: number): Pr
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
requestPermissionsFromUser
(
[
"
com.example.permission1
"
,
"
com.example.permission2
"
,
"
com.example.permission3
"
,
"
com.example.permission4
"
,
"
com.example.permission5
"
],
[
'
com.example.permission1
'
,
'
com.example.permission2
'
,
'
com.example.permission3
'
,
'
com.example.permission4
'
,
'
com.example.permission5
'
],
1
).
then
((
data
)
=>
{
console
.
info
(
"
requestPermissionsFromUser data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
requestPermissionsFromUser data:
'
+
JSON
.
stringify
(
data
));
}
);
```
...
...
@@ -258,7 +258,7 @@ getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getApplicationInfo
((
err
,
data
)
=>
{
console
.
info
(
"
getApplicationInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getApplicationInfo err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -284,7 +284,7 @@ getApplicationInfo(): Promise\<ApplicationInfo>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getApplicationInfo
().
then
((
data
)
=>
{
console
.
info
(
"
getApplicationInfo data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getApplicationInfo data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -310,7 +310,7 @@ getBundleName(callback: AsyncCallback\<string>): void
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
));
console
.
info
(
'
getBundleName err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -336,7 +336,7 @@ getBundleName(): Promise\<string>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getBundleName
().
then
((
data
)
=>
{
console
.
info
(
"
getBundleName data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getBundleName data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -360,7 +360,7 @@ getDisplayOrientation(callback: AsyncCallback\<bundle.DisplayOrientation>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getDisplayOrientation
((
err
,
data
)
=>
{
console
.
info
(
"
getDisplayOrientation err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getDisplayOrientation err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -384,7 +384,7 @@ getDisplayOrientation(): Promise\<bundle.DisplayOrientation>;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getDisplayOrientation
().
then
((
data
)
=>
{
console
.
info
(
"
getDisplayOrientation data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getDisplayOrientation data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -408,7 +408,7 @@ getExternalCacheDir(callback: AsyncCallback\<string>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getExternalCacheDir
((
err
,
data
)
=>
{
console
.
info
(
"
getExternalCacheDir err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getExternalCacheDir err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -432,7 +432,7 @@ getExternalCacheDir(): Promise\<string>;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getExternalCacheDir
().
then
((
data
)
=>
{
console
.
info
(
"
getExternalCacheDir data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getExternalCacheDir data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -459,7 +459,7 @@ import bundle from '@ohos.bundle';
let
context
=
featureAbility
.
getContext
();
let
orientation
=
bundle
.
DisplayOrientation
.
UNSPECIFIED
context
.
setDisplayOrientation
(
orientation
,
(
err
)
=>
{
console
.
info
(
"
setDisplayOrientation err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
'
setDisplayOrientation err:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -486,7 +486,7 @@ import bundle from '@ohos.bundle';
let
context
=
featureAbility
.
getContext
();
let
orientation
=
bundle
.
DisplayOrientation
.
UNSPECIFIED
context
.
setDisplayOrientation
(
orientation
).
then
((
data
)
=>
{
console
.
info
(
"
setDisplayOrientation data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
setDisplayOrientation data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -512,7 +512,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let
context
=
featureAbility
.
getContext
();
let
show
=
true
context
.
setShowOnLockScreen
(
show
,
(
err
)
=>
{
console
.
info
(
"
setShowOnLockScreen err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
'
setShowOnLockScreen err:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -543,7 +543,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let
context
=
featureAbility
.
getContext
();
let
show
=
true
context
.
setShowOnLockScreen
(
show
).
then
((
data
)
=>
{
console
.
info
(
"
setShowOnLockScreen data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
setShowOnLockScreen data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -569,7 +569,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let
context
=
featureAbility
.
getContext
();
let
wakeUp
=
true
context
.
setWakeUpScreen
(
wakeUp
,
(
err
)
=>
{
console
.
info
(
"
setWakeUpScreen err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
'
setWakeUpScreen err:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -600,7 +600,7 @@ import featureAbility from '@ohos.ability.featureAbility';
let
context
=
featureAbility
.
getContext
();
let
wakeUp
=
true
context
.
setWakeUpScreen
(
wakeUp
).
then
((
data
)
=>
{
console
.
info
(
"
setWakeUpScreen data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
setWakeUpScreen data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -627,7 +627,7 @@ getProcessInfo(callback: AsyncCallback\<ProcessInfo>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getProcessInfo
((
err
,
data
)
=>
{
console
.
info
(
"
getProcessInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getProcessInfo err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -653,7 +653,7 @@ getProcessInfo(): Promise\<ProcessInfo>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getProcessInfo
().
then
((
data
)
=>
{
console
.
info
(
"
getProcessInfo data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getProcessInfo data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -681,7 +681,7 @@ getElementName(callback: AsyncCallback\<ElementName>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getElementName
((
err
,
data
)
=>
{
console
.
info
(
"
getElementName err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getElementName err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -709,7 +709,7 @@ getElementName(): Promise\<ElementName>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getElementName
().
then
((
data
)
=>
{
console
.
info
(
"
getElementName data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getElementName data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -733,7 +733,7 @@ getProcessName(callback: AsyncCallback\<string>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getProcessName
((
err
,
data
)
=>
{
console
.
info
(
"
getProcessName err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getProcessName err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -759,7 +759,7 @@ getProcessName(): Promise\<string>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getProcessName
().
then
((
data
)
=>
{
console
.
info
(
"
getProcessName data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getProcessName data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -785,7 +785,7 @@ getCallingBundle(callback: AsyncCallback\<string>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getCallingBundle
((
err
,
data
)
=>
{
console
.
info
(
"
getCallingBundle err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getCallingBundle err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -811,7 +811,7 @@ getCallingBundle(): Promise\<string>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getCallingBundle
().
then
((
data
)
=>
{
console
.
info
(
"
getCallingBundle data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getCallingBundle data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -835,7 +835,7 @@ getCacheDir(callback: AsyncCallback\<string>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getCacheDir
((
err
,
data
)
=>
{
console
.
info
(
"
getCacheDir err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getCacheDir err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -859,7 +859,7 @@ getCacheDir(): Promise\<string>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getCacheDir
().
then
((
data
)
=>
{
console
.
info
(
"
getCacheDir data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getCacheDir data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -883,7 +883,7 @@ getFilesDir(callback: AsyncCallback\<string>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getFilesDir
((
err
,
data
)
=>
{
console
.
info
(
"
getFilesDir err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getFilesDir err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -907,7 +907,7 @@ getFilesDir(): Promise\<string>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getFilesDir
().
then
((
data
)
=>
{
console
.
info
(
"
getFilesDir data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getFilesDir data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -933,7 +933,7 @@ getOrCreateDistributedDir(callback: AsyncCallback\<string>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateDistributedDir
((
err
,
data
)
=>
{
console
.
info
(
"
getOrCreateDistributedDir err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getOrCreateDistributedDir err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -959,7 +959,7 @@ getOrCreateDistributedDir(): Promise\<string>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateDistributedDir
().
then
((
data
)
=>
{
console
.
info
(
"
getOrCreateDistributedDir data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getOrCreateDistributedDir data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -983,7 +983,7 @@ getAppType(callback: AsyncCallback\<string>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getAppType
((
err
,
data
)
=>
{
console
.
info
(
"
getAppType err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getAppType err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1007,7 +1007,7 @@ getAppType(): Promise\<string>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getAppType
().
then
((
data
)
=>
{
console
.
info
(
"
getAppType data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getAppType data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1031,7 +1031,7 @@ getHapModuleInfo(callback: AsyncCallback\<HapModuleInfo>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getHapModuleInfo
((
err
,
data
)
=>
{
console
.
info
(
"
getHapModuleInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getHapModuleInfo err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1055,7 +1055,7 @@ getHapModuleInfo(): Promise\<HapModuleInfo>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getHapModuleInfo
().
then
((
data
)
=>
{
console
.
info
(
"
getHapModuleInfo data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getHapModuleInfo data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1079,7 +1079,7 @@ getAppVersionInfo(callback: AsyncCallback\<AppVersionInfo>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getAppVersionInfo
((
err
,
data
)
=>
{
console
.
info
(
"
getAppVersionInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getAppVersionInfo err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1103,7 +1103,7 @@ getAppVersionInfo(): Promise\<AppVersionInfo>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getAppVersionInfo
().
then
((
data
)
=>
{
console
.
info
(
"
getAppVersionInfo data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getAppVersionInfo data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1127,7 +1127,7 @@ getAbilityInfo(callback: AsyncCallback\<AbilityInfo>): void
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getAbilityInfo
((
err
,
data
)
=>
{
console
.
info
(
"
getAbilityInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getAbilityInfo err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1151,7 +1151,7 @@ getAbilityInfo(): Promise\<AbilityInfo>
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getAbilityInfo
().
then
((
data
)
=>
{
console
.
info
(
"
getAbilityInfo data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
getAbilityInfo data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1196,7 +1196,7 @@ isUpdatingConfigurations(callback: AsyncCallback\<boolean>): void;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
isUpdatingConfigurations
((
err
,
data
)
=>
{
console
.
info
(
"
isUpdatingConfigurations err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
isUpdatingConfigurations err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1220,7 +1220,7 @@ isUpdatingConfigurations(): Promise\<boolean>;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
isUpdatingConfigurations
().
then
((
data
)
=>
{
console
.
info
(
"
isUpdatingConfigurations data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
isUpdatingConfigurations data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -1268,7 +1268,7 @@ printDrawnCompleted(): Promise\<void>;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
context
=
featureAbility
.
getContext
();
context
.
printDrawnCompleted
().
then
((
data
)
=>
{
console
.
info
(
"
printDrawnCompleted data:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
printDrawnCompleted data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-app-processInfo.md
浏览文件 @
b2011405
...
...
@@ -19,8 +19,8 @@ import featureAbility from '@ohos.ability.featureAbility';
let
context
=
featureAbility
.
getContext
();
context
.
getProcessInfo
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
info
(
"
getProcessInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
=
0
)
{
console
.
info
(
'
getProcessInfo err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
let
pid
=
data
.
pid
;
let
processName
=
data
.
processName
;
}
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md
浏览文件 @
b2011405
...
...
@@ -38,17 +38,17 @@ addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): void
var
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
var
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
addAbilityMonitor
(
monitor
,
(
err
:
any
)
=>
{
console
.
info
(
"
addAbilityMonitor callback
"
);
console
.
info
(
'
addAbilityMonitor callback
'
);
});
```
...
...
@@ -78,17 +78,17 @@ addAbilityMonitor(monitor: AbilityMonitor): Promise\<void>;
var
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
var
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
addAbilityMonitor
(
monitor
).
then
(()
=>
{
console
.
info
(
"
addAbilityMonitor promise
"
);
console
.
info
(
'
addAbilityMonitor promise
'
);
});
```
...
...
@@ -115,17 +115,17 @@ removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): v
var
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
var
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
removeAbilityMonitor
(
monitor
,
(
err
:
any
)
=>
{
console
.
info
(
"
removeAbilityMonitor callback
"
);
console
.
info
(
'
removeAbilityMonitor callback
'
);
});
```
...
...
@@ -157,17 +157,17 @@ removeAbilityMonitor(monitor: AbilityMonitor): Promise\<void>;
var
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
var
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
removeAbilityMonitor
(
monitor
).
then
(()
=>
{
console
.
info
(
"
removeAbilityMonitor promise
"
);
console
.
info
(
'
removeAbilityMonitor promise
'
);
});
```
...
...
@@ -194,17 +194,17 @@ waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<UIAbility>)
var
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
var
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
waitAbilityMonitor
(
monitor
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
waitAbilityMonitor callback
"
);
console
.
info
(
'
waitAbilityMonitor callback
'
);
});
```
...
...
@@ -231,17 +231,17 @@ var abilityDelegator;
var
timeout
=
100
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
var
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
waitAbilityMonitor
(
monitor
,
timeout
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
waitAbilityMonitor callback
"
);
console
.
info
(
'
waitAbilityMonitor callback
'
);
});
```
...
...
@@ -274,17 +274,17 @@ waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\<UIAbilit
var
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
var
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
waitAbilityMonitor
(
monitor
).
then
((
data
:
any
)
=>
{
console
.
info
(
"
waitAbilityMonitor promise
"
);
console
.
info
(
'
waitAbilityMonitor promise
'
);
});
```
...
...
@@ -343,10 +343,10 @@ var ability;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
getCurrentTopAbility
((
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
getCurrentTopAbility callback
"
);
console
.
info
(
'
getCurrentTopAbility callback
'
);
ability
=
data
;
var
state
=
abilityDelegator
.
getAbilityState
(
ability
);
console
.
info
(
"
getAbilityState
"
+
state
);
console
.
info
(
'
getAbilityState
'
+
state
);
});
```
...
...
@@ -374,7 +374,7 @@ var ability;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
getCurrentTopAbility
((
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
getCurrentTopAbility callback
"
);
console
.
info
(
'
getCurrentTopAbility callback
'
);
ability
=
data
;
});
```
...
...
@@ -403,7 +403,7 @@ var ability;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
getCurrentTopAbility
().
then
((
data
:
any
)
=>
{
console
.
info
(
"
getCurrentTopAbility promise
"
);
console
.
info
(
'
getCurrentTopAbility promise
'
);
ability
=
data
;
});
```
...
...
@@ -430,13 +430,13 @@ startAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
var
abilityDelegator
;
var
want
=
{
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
bundleName
:
'
bundleName
'
,
abilityName
:
'
abilityName
'
};
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
startAbility
(
want
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
startAbility callback
"
);
console
.
info
(
'
startAbility callback
'
);
});
```
...
...
@@ -467,13 +467,13 @@ startAbility(want: Want): Promise\<void>;
```
ts
var
abilityDelegator
;
var
want
=
{
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
bundleName
:
'
bundleName
'
,
abilityName
:
'
abilityName
'
};
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
startAbility
(
want
).
then
((
data
:
any
)
=>
{
console
.
info
(
"
startAbility promise
"
);
console
.
info
(
'
startAbility promise
'
);
});
```
...
...
@@ -502,10 +502,10 @@ var ability;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
getCurrentTopAbility
((
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
getCurrentTopAbility callback
"
);
console
.
info
(
'
getCurrentTopAbility callback
'
);
ability
=
data
;
abilityDelegator
.
doAbilityForeground
(
ability
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
doAbilityForeground callback
"
);
console
.
info
(
'
doAbilityForeground callback
'
);
});
});
```
...
...
@@ -540,10 +540,10 @@ var ability;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
getCurrentTopAbility
((
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
getCurrentTopAbility callback
"
);
console
.
info
(
'
getCurrentTopAbility callback
'
);
ability
=
data
;
abilityDelegator
.
doAbilityForeground
(
ability
).
then
((
data
:
any
)
=>
{
console
.
info
(
"
doAbilityForeground promise
"
);
console
.
info
(
'
doAbilityForeground promise
'
);
});
});
```
...
...
@@ -573,10 +573,10 @@ var ability;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
getCurrentTopAbility
((
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
getCurrentTopAbility callback
"
);
console
.
info
(
'
getCurrentTopAbility callback
'
);
ability
=
data
;
abilityDelegator
.
doAbilityBackground
(
ability
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
doAbilityBackground callback
"
);
console
.
info
(
'
doAbilityBackground callback
'
);
});
});
```
...
...
@@ -611,10 +611,10 @@ var ability;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
getCurrentTopAbility
((
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
getCurrentTopAbility callback
"
);
console
.
info
(
'
getCurrentTopAbility callback
'
);
ability
=
data
;
abilityDelegator
.
doAbilityBackground
(
ability
).
then
((
data
:
any
)
=>
{
console
.
info
(
"
doAbilityBackground promise
"
);
console
.
info
(
'
doAbilityBackground promise
'
);
});
});
```
...
...
@@ -639,7 +639,7 @@ printSync(msg: string): void;
```
ts
var
abilityDelegator
;
var
msg
=
"
msg
"
;
var
msg
=
'
msg
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
printSync
(
msg
);
...
...
@@ -666,11 +666,11 @@ print(msg: string, callback: AsyncCallback\<void>): void;
```
ts
var
abilityDelegator
;
var
msg
=
"
msg
"
;
var
msg
=
'
msg
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
print
(
msg
,
(
err
:
any
)
=>
{
console
.
info
(
"
print callback
"
);
console
.
info
(
'
print callback
'
);
});
```
...
...
@@ -700,11 +700,11 @@ print(msg: string): Promise\<void>;
```
ts
var
abilityDelegator
;
var
msg
=
"
msg
"
;
var
msg
=
'
msg
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
print
(
msg
).
then
(()
=>
{
console
.
info
(
"
print promise
"
);
console
.
info
(
'
print promise
'
);
});
```
...
...
@@ -729,11 +729,11 @@ executeShellCommand(cmd: string, callback: AsyncCallback\<ShellCmdResult>): void
```
ts
var
abilityDelegator
;
var
cmd
=
"
cmd
"
;
var
cmd
=
'
cmd
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
executeShellCommand callback
"
);
console
.
info
(
'
executeShellCommand callback
'
);
});
```
...
...
@@ -759,12 +759,12 @@ executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback\<S
```
ts
var
abilityDelegator
;
var
cmd
=
"
cmd
"
;
var
cmd
=
'
cmd
'
;
var
timeout
=
100
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
executeShellCommand
(
cmd
,
timeout
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
executeShellCommand callback
"
);
console
.
info
(
'
executeShellCommand callback
'
);
});
```
...
...
@@ -795,12 +795,12 @@ executeShellCommand(cmd: string, timeoutSecs?: number): Promise\<ShellCmdResult>
```
ts
var
abilityDelegator
;
var
cmd
=
"
cmd
"
;
var
cmd
=
'
cmd
'
;
var
timeout
=
100
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
executeShellCommand
(
cmd
,
timeout
).
then
((
data
:
any
)
=>
{
console
.
info
(
"
executeShellCommand promise
"
);
console
.
info
(
'
executeShellCommand promise
'
);
});
```
...
...
@@ -826,11 +826,11 @@ finishTest(msg: string, code: number, callback: AsyncCallback\<void>): void;
```
ts
var
abilityDelegator
;
var
msg
=
"
msg
"
;
var
msg
=
'
msg
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
finishTest
(
msg
,
0
,
(
err
:
any
)
=>
{
console
.
info
(
"
finishTest callback
"
);
console
.
info
(
'
finishTest callback
'
);
});
```
...
...
@@ -861,11 +861,11 @@ finishTest(msg: string, code: number): Promise\<void>;
```
ts
var
abilityDelegator
;
var
msg
=
"
msg
"
;
var
msg
=
'
msg
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
finishTest
(
msg
,
0
).
then
(()
=>
{
console
.
info
(
"
finishTest promise
"
);
console
.
info
(
'
finishTest promise
'
);
});
```
...
...
@@ -890,13 +890,13 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<vo
var
abilityDelegator
;
var
monitor
=
{
moduleName
:
"
moduleName
"
,
srcEntrance
:
"
srcEntrance
"
,
}
moduleName
:
'
moduleName
'
,
srcEntrance
:
'
srcEntrance
'
,
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
addAbilityStageMonitor
(
monitor
,
(
err
:
any
)
=>
{
console
.
info
(
"
addAbilityStageMonitor callback
"
);
console
.
info
(
'
addAbilityStageMonitor callback
'
);
});
```
...
...
@@ -928,13 +928,13 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
var
abilityDelegator
;
var
monitor
=
{
moduleName
:
"
moduleName
"
,
srcEntrance
:
"
srcEntrance
"
,
}
moduleName
:
'
moduleName
'
,
srcEntrance
:
'
srcEntrance
'
,
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
addAbilityStageMonitor
(
monitor
).
then
(()
=>
{
console
.
info
(
"
addAbilityStageMonitor promise
"
);
console
.
info
(
'
addAbilityStageMonitor promise
'
);
});
```
...
...
@@ -959,13 +959,13 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\
var
abilityDelegator
;
var
monitor
=
{
moduleName
:
"
moduleName
"
,
srcEntrance
:
"
srcEntrance
"
,
}
moduleName
:
'
moduleName
'
,
srcEntrance
:
'
srcEntrance
'
,
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
removeAbilityStageMonitor
(
monitor
,
(
err
:
any
)
=>
{
console
.
info
(
"
removeAbilityStageMonitor callback
"
);
console
.
info
(
'
removeAbilityStageMonitor callback
'
);
});
```
...
...
@@ -997,13 +997,13 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
var
abilityDelegator
;
var
monitor
=
{
moduleName
:
"
moduleName
"
,
srcEntrance
:
"
srcEntrance
"
,
}
moduleName
:
'
moduleName
'
,
srcEntrance
:
'
srcEntrance
'
,
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
removeAbilityStageMonitor
(
monitor
).
then
(()
=>
{
console
.
info
(
"
removeAbilityStageMonitor promise
"
);
console
.
info
(
'
removeAbilityStageMonitor promise
'
);
});
```
...
...
@@ -1028,17 +1028,17 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<A
var
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
var
monitor
=
{
moduleName
:
"
moduleName
"
,
srcEntrance
:
"
srcEntrance
"
,
}
moduleName
:
'
moduleName
'
,
srcEntrance
:
'
srcEntrance
'
,
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
waitAbilityStageMonitor
(
monitor
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
waitAbilityStageMonitor callback
"
);
console
.
info
(
'
waitAbilityStageMonitor callback
'
);
});
```
...
...
@@ -1069,17 +1069,17 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise
var
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
var
monitor
=
{
moduleName
:
"
moduleName
"
,
srcEntrance
:
"
srcEntrance
"
,
}
moduleName
:
'
moduleName
'
,
srcEntrance
:
'
srcEntrance
'
,
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
waitAbilityStageMonitor
(
monitor
).
then
((
data
:
any
)
=>
{
console
.
info
(
"
waitAbilityStageMonitor promise
"
);
console
.
info
(
'
waitAbilityStageMonitor promise
'
);
});
```
...
...
@@ -1106,16 +1106,16 @@ var abilityDelegator;
var
timeout
=
100
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
var
monitor
=
{
moduleName
:
"
moduleName
"
,
srcEntrance
:
"
srcEntrance
"
,
}
moduleName
:
'
moduleName
'
,
srcEntrance
:
'
srcEntrance
'
,
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
waitAbilityStageMonitor
(
monitor
,
timeout
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
waitAbilityStageMonitor callback
"
);
console
.
info
(
'
waitAbilityStageMonitor callback
'
);
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md
浏览文件 @
b2011405
...
...
@@ -30,20 +30,20 @@ Ability监听器
**示例:**
```
ts
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
let
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
addAbilityMonitor
(
monitor
,
(
err
:
any
)
=>
{
console
.
info
(
"
addAbilityMonitor callback
"
);
console
.
info
(
'
addAbilityMonitor callback
'
);
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityRunningInfo.md
浏览文件 @
b2011405
...
...
@@ -30,15 +30,15 @@ AbilityRunningInfo模块提供对Ability运行的相关信息和状态的定义
```
ts
import
abilitymanager
from
'
@ohos.application.abilityManager
'
;
abilitymanager
.
getAbilityRunningInfos
((
err
,
data
)
=>
{
console
.
log
(
"
getAbilityRunningInfos err:
"
+
err
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
getAbilityRunningInfos err:
'
+
err
+
'
data:
'
+
JSON
.
stringify
(
data
));
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
let
abilityinfo
=
data
[
i
];
console
.
log
(
"
abilityinfo.ability:
"
+
JSON
.
stringify
(
abilityinfo
.
ability
));
console
.
log
(
"
abilityinfo.pid:
"
+
JSON
.
stringify
(
abilityinfo
.
pid
));
console
.
log
(
"
abilityinfo.uid:
"
+
JSON
.
stringify
(
abilityinfo
.
uid
));
console
.
log
(
"
abilityinfo.processName:
"
+
JSON
.
stringify
(
abilityinfo
.
processName
));
console
.
log
(
"
abilityinfo.startTime:
"
+
JSON
.
stringify
(
abilityinfo
.
startTime
));
console
.
log
(
"
abilityinfo.abilityState:
"
+
JSON
.
stringify
(
abilityinfo
.
abilityState
));
console
.
log
(
'
abilityinfo.ability:
'
+
JSON
.
stringify
(
abilityinfo
.
ability
));
console
.
log
(
'
abilityinfo.pid:
'
+
JSON
.
stringify
(
abilityinfo
.
pid
));
console
.
log
(
'
abilityinfo.uid:
'
+
JSON
.
stringify
(
abilityinfo
.
uid
));
console
.
log
(
'
abilityinfo.processName:
'
+
JSON
.
stringify
(
abilityinfo
.
processName
));
console
.
log
(
'
abilityinfo.startTime:
'
+
JSON
.
stringify
(
abilityinfo
.
startTime
));
console
.
log
(
'
abilityinfo.abilityState:
'
+
JSON
.
stringify
(
abilityinfo
.
abilityState
));
}
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityStageMonitor.md
浏览文件 @
b2011405
...
...
@@ -11,15 +11,15 @@
**示例:**
```
ts
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
;
let
monitor
=
{
moduleName
:
"
feature_as1
"
,
srcEntrance
:
"
./ets/Application/MyAbilityStage.ts
"
,
moduleName
:
'
feature_as1
'
,
srcEntrance
:
'
./ets/Application/MyAbilityStage.ts
'
,
};
let
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
waitAbilityStageMonitor
(
monitor
,
(
error
,
data
)
=>
{
console
.
info
(
"
stageMonitor waitAbilityStageMonitor, abilityStage =
"
+
JSON
.
stringify
(
data
));
console
.
info
(
'
stageMonitor waitAbilityStageMonitor, abilityStage =
'
+
JSON
.
stringify
(
data
));
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-accessibilityExtensionContext.md
浏览文件 @
b2011405
...
...
@@ -14,7 +14,7 @@ AccessibilityExtensionContext是AccessibilityExtensionAbility上下文环境,
在使用AccessibilityExtensionContext的功能前,需要通过AccessibilityExtensionAbility子类实例获取AccessibilityExtensionContex的实例。
```
ts
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
;
let
axContext
;
class
MainAbility
extends
AccessibilityExtensionAbility
{
onConnect
():
void
{
...
...
@@ -541,7 +541,7 @@ injectGesture(gesturePath: GesturePath): Promise\<void>;
**示例:**
```
ts
import
GesturePath
from
"
@ohos.accessibility.GesturePath
"
;
import
GesturePath
from
'
@ohos.accessibility.GesturePath
'
;
import
GesturePoint
from
'
@ohos.accessibility.GesturePoint
'
;
let
gesturePath
=
new
GesturePath
.
GesturePath
(
100
);
try
{
...
...
@@ -584,7 +584,7 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\<void>): void
**示例:**
```
ts
import
GesturePath
from
"
@ohos.accessibility.GesturePath
"
;
import
GesturePath
from
'
@ohos.accessibility.GesturePath
'
;
import
GesturePoint
from
'
@ohos.accessibility.GesturePoint
'
;
let
gesturePath
=
new
GesturePath
.
GesturePath
(
100
);
try
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-appStateData.md
浏览文件 @
b2011405
...
...
@@ -14,7 +14,7 @@
**示例:**
```
ts
import
appManager
from
"
@ohos.application.appManager
"
import
appManager
from
"
@ohos.application.appManager
"
;
appManager
.
getForegroundApplications
((
error
,
data
)
=>
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md
浏览文件 @
b2011405
...
...
@@ -15,9 +15,9 @@ ApplicationContext模块提供开发者应用级别的的上下文的能力,
let
applicationContext
=
this
.
context
.
getApplicationContext
();
```
## ApplicationContext.on(type:
"abilityLifecycle"
, callback: AbilityLifecycleCallback)
## ApplicationContext.on(type:
'abilityLifecycle'
, callback: AbilityLifecycleCallback)
on(type:
"abilityLifecycle"
, callback: AbilityLifecycleCallback):
**number**
;
on(type:
'abilityLifecycle'
, callback: AbilityLifecycleCallback):
**number**
;
注册监听应用内生命周期
...
...
@@ -27,7 +27,7 @@ on(type: "abilityLifecycle", callback: AbilityLifecycleCallback): **number**;
| 参数名 | 类型 | 必填 | 说明 |
| ------------------------ | -------- | ---- | ------------------------------ |
| type |
"abilityLifecycle"
| 是 | 监听事件的类型。 |
| type |
'abilityLifecycle'
| 是 | 监听事件的类型。 |
| callback |
[
AbilityLifecycleCallback
](
js-apis-app-ability-abilityLifecycleCallback.md
)
| 是 | 回调方法,返回注册监听事件的ID。 |
**返回值:**
...
...
@@ -45,52 +45,52 @@ let lifecycleId;
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
()
{
console
.
log
(
"
MyAbility onCreate
"
)
console
.
log
(
'
MyAbility onCreate
'
);
let
AbilityLifecycleCallback
=
{
onAbilityCreate
(
ability
)
{
console
.
log
(
"
AbilityLifecycleCallback onAbilityCreate ability:
"
+
ability
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityCreate ability:
'
+
ability
);
},
onWindowStageCreate
(
ability
,
windowStage
)
{
console
.
log
(
"
AbilityLifecycleCallback onWindowStageCreate ability:
"
+
ability
);
console
.
log
(
"
AbilityLifecycleCallback onWindowStageCreate windowStage:
"
+
windowStage
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageCreate ability:
'
+
ability
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageCreate windowStage:
'
+
windowStage
);
},
onWindowStageActive
(
ability
,
windowStage
)
{
console
.
log
(
"
AbilityLifecycleCallback onWindowStageActive ability:
"
+
ability
);
console
.
log
(
"
AbilityLifecycleCallback onWindowStageActive windowStage:
"
+
windowStage
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageActive ability:
'
+
ability
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageActive windowStage:
'
+
windowStage
);
},
onWindowStageInactive
(
ability
,
windowStage
)
{
console
.
log
(
"
AbilityLifecycleCallback onWindowStageInactive ability:
"
+
ability
);
console
.
log
(
"
AbilityLifecycleCallback onWindowStageInactive windowStage:
"
+
windowStage
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageInactive ability:
'
+
ability
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageInactive windowStage:
'
+
windowStage
);
},
onWindowStageDestroy
(
ability
,
windowStage
)
{
console
.
log
(
"
AbilityLifecycleCallback onWindowStageDestroy ability:
"
+
ability
);
console
.
log
(
"
AbilityLifecycleCallback onWindowStageDestroy windowStage:
"
+
windowStage
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageDestroy ability:
'
+
ability
);
console
.
log
(
'
AbilityLifecycleCallback onWindowStageDestroy windowStage:
'
+
windowStage
);
},
onAbilityDestroy
(
ability
)
{
console
.
log
(
"
AbilityLifecycleCallback onAbilityDestroy ability:
"
+
ability
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityDestroy ability:
'
+
ability
);
},
onAbilityForeground
(
ability
)
{
console
.
log
(
"
AbilityLifecycleCallback onAbilityForeground ability:
"
+
ability
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityForeground ability:
'
+
ability
);
},
onAbilityBackground
(
ability
)
{
console
.
log
(
"
AbilityLifecycleCallback onAbilityBackground ability:
"
+
ability
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityBackground ability:
'
+
ability
);
},
onAbilityContinue
(
ability
)
{
console
.
log
(
"
AbilityLifecycleCallback onAbilityContinue ability:
"
+
ability
);
console
.
log
(
'
AbilityLifecycleCallback onAbilityContinue ability:
'
+
ability
);
}
}
// 1.通过context属性获取applicationContext
let
applicationContext
=
this
.
context
.
getApplicationContext
();
// 2.通过applicationContext注册监听应用内生命周期
lifecycleId
=
applicationContext
.
on
(
"
abilityLifecycle
"
,
AbilityLifecycleCallback
);
console
.
log
(
"
registerAbilityLifecycleCallback number:
"
+
JSON
.
stringify
(
lifecycleId
));
lifecycleId
=
applicationContext
.
on
(
'
abilityLifecycle
'
,
AbilityLifecycleCallback
);
console
.
log
(
'
registerAbilityLifecycleCallback number:
'
+
JSON
.
stringify
(
lifecycleId
));
}
}
```
## ApplicationContext.off(type:
"abilityLifecycle"
, callbackId: number, callback: AsyncCallback<void>)
## ApplicationContext.off(type:
'abilityLifecycle'
, callbackId: number, callback: AsyncCallback<void>)
off(type:
"abilityLifecycle"
, callbackId:
**number**
, callback: AsyncCallback
<
**void**
>
):
**void**
;
off(type:
'abilityLifecycle'
, callbackId:
**number**
, callback: AsyncCallback
<
**void**
>
):
**void**
;
取消监听应用内生命周期
...
...
@@ -100,7 +100,7 @@ off(type: "abilityLifecycle", callbackId: **number**, callback: AsyncCallback<*
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | -------- | ---- | -------------------------- |
| type |
"abilityLifecycle"
| 是 | 取消监听事件的类型。 |
| type |
'abilityLifecycle'
| 是 | 取消监听事件的类型。 |
| callbackId | number | 是 | 注册监听应用内生命周期的ID。 |
| callback | AsyncCallback
\<
void> | 是 | 回调方法。 |
...
...
@@ -114,17 +114,17 @@ let lifecycleId;
export
default
class
EntryAbility
extends
UIAbility
{
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
console
.
log
(
"
stage applicationContext:
"
+
applicationContext
);
applicationContext
.
off
(
type
:
"
abilityLifecycle
"
,
lifecycleId
,
(
error
,
data
)
=>
{
console
.
log
(
"
unregisterAbilityLifecycleCallback success, err:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
stage applicationContext:
'
+
applicationContext
);
applicationContext
.
off
(
type
:
'
abilityLifecycle
'
,
lifecycleId
,
(
error
,
data
)
=>
{
console
.
log
(
'
unregisterAbilityLifecycleCallback success, err:
'
+
JSON
.
stringify
(
error
));
});
}
}
```
## ApplicationContext.off(type:
"abilityLifecycle"
, callbackId: number)
## ApplicationContext.off(type:
'abilityLifecycle'
, callbackId: number)
off(type:
"abilityLifecycle"
, callbackId:
**number**
):
**void**
;
off(type:
'abilityLifecycle'
, callbackId:
**number**
):
**void**
;
取消监听应用内生命周期
...
...
@@ -134,28 +134,28 @@ off(type: "abilityLifecycle", callbackId: **number**): **void**;
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | -------- | ---- | -------------------------- |
| type |
"abilityLifecycle"
| 是 | 取消监听事件的类型。 |
| type |
'abilityLifecycle'
| 是 | 取消监听事件的类型。 |
| callbackId | number | 是 | 注册监听应用内生命周期的ID。 |
**示例:**
```
ts
import
Ability
from
"
@ohos.app.ability.UIAbility
"
;
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
let
lifecycleId
;
export
default
class
MyAbility
extends
Ability
{
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
console
.
log
(
"
stage applicationContext:
"
+
applicationContext
);
applicationContext
.
off
(
type
:
"
abilityLifecycle
"
,
lifecycleId
);
console
.
log
(
'
stage applicationContext:
'
+
applicationContext
);
applicationContext
.
off
(
type
:
'
abilityLifecycle
'
,
lifecycleId
);
}
}
```
## ApplicationContext.on(type:
"environment"
, callback: EnvironmentCallback)
## ApplicationContext.on(type:
'environment'
, callback: EnvironmentCallback)
on(type:
"environment"
, callback: EnvironmentCallback):
**number**
;
on(type:
'environment'
, callback: EnvironmentCallback):
**number**
;
注册对系统环境变化的监听。使用callback异步回调。
...
...
@@ -165,7 +165,7 @@ on(type: "environment", callback: EnvironmentCallback): **number**;
| 参数名 | 类型 | 必填 | 说明 |
| ------------------------ | -------- | ---- | ------------------------------ |
| type |
"environment"
| 是 | 监听事件的类型。 |
| type |
'environment'
| 是 | 监听事件的类型。 |
| callback |
[
EnvironmentCallback
](
js-apis-app-ability-environmentCallback.md
)
| 是 | 回调方法,返回注册监听事件的ID。 |
**返回值:**
...
...
@@ -183,28 +183,28 @@ let callbackId;
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
()
{
console
.
log
(
"
MyAbility onCreate
"
)
console
.
log
(
'
MyAbility onCreate
'
)
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
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
));
callbackId
=
applicationContext
.
on
(
'
environment
'
,
EnvironmentCallback
);
console
.
log
(
'
registerEnvironmentCallback number:
'
+
JSON
.
stringify
(
callbackId
));
}
}
```
## ApplicationContext.off(type:
"environment"
, callbackId: number, callback: AsyncCallback<void>)
## ApplicationContext.off(type:
'environment'
, callbackId: number, callback: AsyncCallback<void>)
off(type:
"environment"
, callbackId:
**number**
, callback: AsyncCallback
<
**void**
>
):
**void**
;
off(type:
'environment'
, callbackId:
**number**
, callback: AsyncCallback
<
**void**
>
):
**void**
;
取消对系统环境变化的监听。使用callback异步回调。
...
...
@@ -214,7 +214,7 @@ off(type: "environment", callbackId: **number**, callback: AsyncCallback<**void
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | -------- | ---- | -------------------------- |
| type |
"environment"
| 是 | 取消监听事件的类型。 |
| type |
'environment'
| 是 | 取消监听事件的类型。 |
| callbackId | number | 是 | 注册监听系统环境变化的ID。 |
| callback | AsyncCallback
\<
void> | 是 | 回调方法。 |
...
...
@@ -228,16 +228,16 @@ let callbackId;
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
));
applicationContext
.
off
(
'
environment
'
,
callbackId
,
(
error
,
data
)
=>
{
console
.
log
(
'
unregisterEnvironmentCallback success, err:
'
+
JSON
.
stringify
(
error
));
});
}
}
```
## ApplicationContext.off(type:
"environment"
, callbackId: number)
## ApplicationContext.off(type:
'environment'
, callbackId: number)
off(type:
"environment"
, callbackId:
**number**
, callback: AsyncCallback
<
**void**
>
):
**void**
;
off(type:
'environment'
, callbackId:
**number**
, callback: AsyncCallback
<
**void**
>
):
**void**
;
取消对系统环境变化的监听。使用callback异步回调。
...
...
@@ -247,20 +247,20 @@ off(type: "environment", callbackId: **number**, callback: AsyncCallback<**void
| 参数名 | 类型 | 必填 | 说明 |
| ------------- | -------- | ---- | -------------------------- |
| type |
"environment"
| 是 | 取消监听事件的类型。 |
| type |
'environment'
| 是 | 取消监听事件的类型。 |
| callbackId | number | 是 | 注册监听系统环境变化的ID。 |
**示例:**
```
ts
import
Ability
from
"
@ohos.app.ability.UIAbility
"
;
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
let
callbackId
;
export
default
class
MyAbility
extends
Ability
{
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
off
(
"
environment
"
,
callbackId
);
applicationContext
.
off
(
'
environment
'
,
callbackId
);
}
}
```
...
...
@@ -281,16 +281,16 @@ getProcessRunningInformation(): Promise\<Array\<ProcessRunningInformation>>;
| 类型 | 说明 |
| -------- | -------- |
| Promise
\<
Array
\<
[
ProcessRunningInformation
](
js-apis-inner-application-processRunningInfo
rmation
.md
)
>> | 以Promise方式返回接口运行结果及有关运行进程的信息,可进行错误处理或其他自定义处理。 |
| Promise
\<
Array
\<
[
ProcessRunningInformation
](
js-apis-inner-application-processRunningInfo.md
)
>> | 以Promise方式返回接口运行结果及有关运行进程的信息,可进行错误处理或其他自定义处理。 |
**示例:**
```
ts
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
getProcessRunningInformation
().
then
((
data
)
=>
{
console
.
log
(
"
The process running information is:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
The process running information is:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
"
error:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
error:
'
+
JSON
.
stringify
(
error
));
});
```
...
...
@@ -310,7 +310,7 @@ getProcessRunningInformation(callback: AsyncCallback\<Array\<ProcessRunningInfor
| 类型 | 说明 |
| -------- | -------- |
|AsyncCallback
\<
Array
\<
[
ProcessRunningInformation
](
js-apis-inner-application-processRunningInfo
rmation
.md
)
>> | 以回调方式返回接口运行结果及有关运行进程的信息,可进行错误处理或其他自定义处理。 |
|AsyncCallback
\<
Array
\<
[
ProcessRunningInformation
](
js-apis-inner-application-processRunningInfo.md
)
>> | 以回调方式返回接口运行结果及有关运行进程的信息,可进行错误处理或其他自定义处理。 |
**示例:**
...
...
@@ -318,9 +318,9 @@ getProcessRunningInformation(callback: AsyncCallback\<Array\<ProcessRunningInfor
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
getProcessRunningInformation
((
err
,
data
)
=>
{
if
(
err
.
code
!==
0
)
{
console
.
error
(
"
getProcessRunningInformation faile, err:
"
+
JSON
.
stringify
(
err
));
console
.
error
(
'
getProcessRunningInformation faile, err:
'
+
JSON
.
stringify
(
err
));
}
else
{
console
.
log
(
"
The process running information is:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
The process running information is:
'
+
JSON
.
stringify
(
data
));
}
})
```
...
...
@@ -344,9 +344,9 @@ killProcessesBySelf(): Promise<void>;
```
ts
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
killProcessesBySelf
().
then
((
data
)
=>
{
console
.
log
(
"
The process running information is:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
The process running information is:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
error
(
"
error:
"
+
JSON
.
stringify
(
error
));
console
.
error
(
'
error:
'
+
JSON
.
stringify
(
error
));
});
```
...
...
@@ -370,7 +370,7 @@ killProcessesBySelf(callback: AsyncCallback<void>);
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
killProcessesBySelf
(
err
=>
{
if
(
err
.
code
!==
0
)
{
console
.
error
(
"
killProcessesBySelf faile, err:
"
+
JSON
.
stringify
(
err
));
console
.
error
(
'
killProcessesBySelf faile, err:
'
+
JSON
.
stringify
(
err
));
}
})
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md
浏览文件 @
b2011405
...
...
@@ -16,7 +16,7 @@
**示例:**
```
ts
import
appManager
from
"
@ohos.application.appManager
"
import
appManager
from
"
@ohos.application.appManager
"
;
let
applicationStateObserver
=
{
onForegroundApplicationChanged
(
appStateData
)
{
...
...
@@ -34,6 +34,6 @@ let applicationStateObserver = {
onProcessStateChanged
(
processData
)
{
console
.
log
(
'
onProcessStateChanged onProcessStateChanged:
'
+
JSON
.
stringify
(
processData
));
}
}
}
;
let
observerCode
=
appManager
.
registerApplicationStateObserver
(
applicationStateObserver
);
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md
浏览文件 @
b2011405
...
...
@@ -22,7 +22,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class
MainAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
// MainAbility onCreate, isStageMode: true
console
.
log
(
"
MainAbility onCreate, isStageMode:
"
+
this
.
context
.
stageMode
);
console
.
log
(
'
MainAbility onCreate, isStageMode:
'
+
this
.
context
.
stageMode
);
}
}
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md
浏览文件 @
b2011405
...
...
@@ -49,7 +49,7 @@ createBundleContext(bundleName: string): Context;
**示例:**
```
ts
let
bundleContext
=
this
.
context
.
createBundleContext
(
"
com.example.test
"
);
let
bundleContext
=
this
.
context
.
createBundleContext
(
'
com.example.test
'
);
```
## Context.createModuleContext
...
...
@@ -75,7 +75,7 @@ createModuleContext(moduleName: string): Context;
**示例:**
```
ts
let
moduleContext
=
this
.
context
.
createModuleContext
(
"
entry
"
);
let
moduleContext
=
this
.
context
.
createModuleContext
(
'
entry
'
);
```
createModuleContext(bundleName: string, moduleName: string): Context;
...
...
@@ -100,7 +100,7 @@ createModuleContext(bundleName: string, moduleName: string): Context;
**示例:**
```
ts
let
moduleContext
=
this
.
context
.
createModuleContext
(
"
com.example.test
"
,
"
entry
"
);
let
moduleContext
=
this
.
context
.
createModuleContext
(
'
com.example.test
'
,
'
entry
'
);
```
## Context.getApplicationContext
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueCallback.md
浏览文件 @
b2011405
...
...
@@ -14,11 +14,11 @@
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
;
let
continueDeviceInfo
=
{
srcDeviceId
:
"
123
"
,
dstDeviceId
:
"
456
"
,
srcDeviceId
:
'
123
'
,
dstDeviceId
:
'
456
'
,
missionId
:
123
,
wantParam
:
{
"
key
"
:
"
value
"
'
key
'
:
'
value
'
}
};
...
...
@@ -26,7 +26,7 @@
onContinueDone
(
result
)
{
console
.
log
(
'
onContinueDone, result:
'
+
JSON
.
stringify
(
result
));
}
}
}
;
distributedMissionManager
.
continueMission
(
continueDeviceInfo
,
continueCallback
,
(
error
)
=>
{
if
(
error
.
code
!=
0
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueDeviceInfo.md
浏览文件 @
b2011405
...
...
@@ -17,11 +17,11 @@
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
;
let
continueDeviceInfo
=
{
srcDeviceId
:
"
123
"
,
dstDeviceId
:
"
456
"
,
srcDeviceId
:
'
123
'
,
dstDeviceId
:
'
456
'
,
missionId
:
123
,
wantParam
:
{
"
key
"
:
"
value
"
'
key
'
:
'
value
'
}
};
...
...
@@ -29,7 +29,7 @@
onContinueDone
(
result
)
{
console
.
log
(
'
onContinueDone, result:
'
+
JSON
.
stringify
(
result
));
}
}
}
;
distributedMissionManager
.
continueMission
(
continueDeviceInfo
,
continueCallback
,
(
error
)
=>
{
if
(
error
.
code
!=
0
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md
浏览文件 @
b2011405
...
...
@@ -25,6 +25,6 @@ let observer = {
onUnhandledException
(
errorMsg
)
{
console
.
log
(
'
onUnhandledException, errorMsg:
'
+
JSON
.
stringify
(
errorMsg
));
}
}
errorManager
.
registerErrorObserver
(
observer
)
}
;
errorManager
.
registerErrorObserver
(
observer
)
;
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md
浏览文件 @
b2011405
...
...
@@ -15,10 +15,10 @@ EventHub模块提供了事件中心,提供订阅、取消订阅、触发事件
import
Ability
from
'
@ohos.application.Ability
'
;
export
default
class
MainAbility
extends
Ability
{
func1
(){
console
.
log
(
"
func1 is called
"
);
console
.
log
(
'
func1 is called
'
);
}
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func1
);
this
.
context
.
eventHub
.
on
(
'
123
'
,
this
.
func1
);
}
}
```
...
...
@@ -45,17 +45,17 @@ on(event: string, callback: Function): void;
export
default
class
MainAbility
extends
Ability
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func1
);
this
.
context
.
eventHub
.
on
(
"
123
"
,
()
=>
{
console
.
log
(
"
call anonymous func 1
"
);
this
.
context
.
eventHub
.
on
(
'
123
'
,
this
.
func1
);
this
.
context
.
eventHub
.
on
(
'
123
'
,
()
=>
{
console
.
log
(
'
call anonymous func 1
'
);
});
// 结果:
// func1 is called
// call anonymous func 1
this
.
context
.
eventHub
.
emit
(
"
123
"
);
this
.
context
.
eventHub
.
emit
(
'
123
'
);
}
func1
()
{
console
.
log
(
"
func1 is called
"
);
console
.
log
(
'
func1 is called
'
);
}
}
```
...
...
@@ -83,17 +83,17 @@ off(event: string, callback?: Function): void;
export
default
class
MainAbility
extends
Ability
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func1
);
this
.
context
.
eventHub
.
off
(
"
123
"
,
this
.
func1
);
//取消订阅func1
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func1
);
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func2
);
this
.
context
.
eventHub
.
off
(
"
123
"
);
//取消订阅func1和func2
this
.
context
.
eventHub
.
on
(
'
123
'
,
this
.
func1
);
this
.
context
.
eventHub
.
off
(
'
123
'
,
this
.
func1
);
//取消订阅func1
this
.
context
.
eventHub
.
on
(
'
123
'
,
this
.
func1
);
this
.
context
.
eventHub
.
on
(
'
123
'
,
this
.
func2
);
this
.
context
.
eventHub
.
off
(
'
123
'
);
//取消订阅func1和func2
}
func1
()
{
console
.
log
(
"
func1 is called
"
);
console
.
log
(
'
func1 is called
'
);
}
func2
()
{
console
.
log
(
"
func2 is called
"
);
console
.
log
(
'
func2 is called
'
);
}
}
```
...
...
@@ -121,19 +121,19 @@ emit(event: string, ...args: Object[]): void;
export
default
class
MainAbility
extends
Ability
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
123
"
,
this
.
func1
);
this
.
context
.
eventHub
.
on
(
'
123
'
,
this
.
func1
);
// 结果:
// func1 is called,undefined,undefined
this
.
context
.
eventHub
.
emit
(
"
123
"
);
this
.
context
.
eventHub
.
emit
(
'
123
'
);
// 结果:
// func1 is called,1,undefined
this
.
context
.
eventHub
.
emit
(
"
123
"
,
1
);
this
.
context
.
eventHub
.
emit
(
'
123
'
,
1
);
// 结果:
// func1 is called,1,2
this
.
context
.
eventHub
.
emit
(
"
123
"
,
1
,
2
);
this
.
context
.
eventHub
.
emit
(
'
123
'
,
1
,
2
);
}
func1
(
a
,
b
)
{
console
.
log
(
"
func1 is called,
"
+
a
+
"
,
"
+
b
);
console
.
log
(
'
func1 is called,
'
+
a
+
'
,
'
+
b
);
}
}
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md
浏览文件 @
b2011405
...
...
@@ -31,8 +31,8 @@ ExtensionContext主要用于查询所属Extension的信息、Module的配置信
三个Module内都定义一个相同名称的ServiceExtension:
```
ts
import
ServiceExtension
from
'
@ohos.app.ability.ServiceExtensionAbility
'
import
Want
from
'
@ohos.application.Want
'
import
ServiceExtension
from
'
@ohos.app.ability.ServiceExtensionAbility
'
;
import
Want
from
'
@ohos.application.Want
'
;
export
default
class
TheServiceExtension
extends
ServiceExtension
{
onCreate
(
want
:
Want
)
{
console
.
log
(
'
ServiceAbility onCreate, want:
'
+
want
.
abilityName
);
...
...
@@ -61,14 +61,14 @@ export default class TheServiceExtension extends ServiceExtension {
在entry的MainAbility的onCreate回调内启动ServiceExtension
```
ts
import
Ability
from
'
@ohos.app.ability.Ability
'
import
Ability
from
'
@ohos.app.ability.Ability
'
;
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
"
[Demo] MainAbility onCreate
"
);
console
.
log
(
'
[Demo] MainAbility onCreate
'
);
let
wantExt
=
{
deviceId
:
""
,
bundleName
:
"
com.example.TheServiceExtension
"
,
abilityName
:
"
TheServiceExtension
"
,
deviceId
:
''
,
bundleName
:
'
com.example.TheServiceExtension
'
,
abilityName
:
'
TheServiceExtension
'
,
};
this
.
context
.
startServiceExtensionAbility
(
wantExt
);
}
...
...
@@ -83,8 +83,8 @@ export default class ServiceModel {
constructor
()
{}
executeTask
()
{
if
(
globalThis
.
ExtensionContext
==
undefined
)
{
console
.
log
(
"
ERROR, ServiceExtension does not exist
"
);
if
(
globalThis
.
ExtensionContext
==
=
undefined
)
{
console
.
log
(
'
ERROR, ServiceExtension does not exist
'
);
return
;
}
...
...
@@ -92,20 +92,20 @@ export default class ServiceModel {
this
.
moduleName
=
moduleInfo
.
name
;
// 根据moduleName执行不同的业务逻辑,实现对不同性能设备的区分
switch
(
this
.
moduleName
)
{
case
"
highPerformance
"
:
console
.
log
(
"
This is high performance device.
"
);
case
'
highPerformance
'
:
console
.
log
(
'
This is high performance device.
'
);
// 执行对应业务逻辑
break
;
case
"
midPerformance
"
:
console
.
log
(
"
This is mid performance device.
"
);
case
'
midPerformance
'
:
console
.
log
(
'
This is mid performance device.
'
);
// 执行对应业务逻辑
break
;
case
"
lowPerformance
"
:
console
.
log
(
"
This is low performance device.
"
);
case
'
lowPerformance
'
:
console
.
log
(
'
This is low performance device.
'
);
// 执行对应业务逻辑
break
;
default
:
console
.
log
(
"
ERROR, invalid moduleName.
"
);
console
.
log
(
'
ERROR, invalid moduleName.
'
);
break
;
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md
浏览文件 @
b2011405
...
...
@@ -30,16 +30,16 @@ ExtensionRunningInfo模块提供对Extension运行的相关信息和类型进行
import
abilityManager
from
'
@ohos.application.abilityManager
'
;
let
upperLimit
=
1
;
abilityManager
.
getExtensionRunningInfos
(
upperLimit
,
(
err
,
data
)
=>
{
console
.
log
(
"
getExtensionRunningInfos err:
"
+
err
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
getExtensionRunningInfos err:
'
+
err
+
'
data:
'
+
JSON
.
stringify
(
data
));
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
let
extensionRunningInfo
=
data
[
i
];
console
.
log
(
"
extensionRunningInfo.extension:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
extension
));
console
.
log
(
"
extensionRunningInfo.pid:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
pid
));
console
.
log
(
"
extensionRunningInfo.uid:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
uid
));
console
.
log
(
"
extensionRunningInfo.processName:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
processName
));
console
.
log
(
"
extensionRunningInfo.startTime:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
startTime
));
console
.
log
(
"
extensionRunningInfo.clientPackage:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
clientPackage
));
console
.
log
(
"
extensionRunningInfo.type:
"
+
JSON
.
stringify
(
extensionRunningInfo
.
type
));
console
.
log
(
'
extensionRunningInfo.extension:
'
+
JSON
.
stringify
(
extensionRunningInfo
.
extension
));
console
.
log
(
'
extensionRunningInfo.pid:
'
+
JSON
.
stringify
(
extensionRunningInfo
.
pid
));
console
.
log
(
'
extensionRunningInfo.uid:
'
+
JSON
.
stringify
(
extensionRunningInfo
.
uid
));
console
.
log
(
'
extensionRunningInfo.processName:
'
+
JSON
.
stringify
(
extensionRunningInfo
.
processName
));
console
.
log
(
'
extensionRunningInfo.startTime:
'
+
JSON
.
stringify
(
extensionRunningInfo
.
startTime
));
console
.
log
(
'
extensionRunningInfo.clientPackage:
'
+
JSON
.
stringify
(
extensionRunningInfo
.
clientPackage
));
console
.
log
(
'
extensionRunningInfo.type:
'
+
JSON
.
stringify
(
extensionRunningInfo
.
type
));
}
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md
浏览文件 @
b2011405
...
...
@@ -21,8 +21,8 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
let
formContext
=
this
.
context
;
// 获取FormExtensionContext
// ...
let
dataObj1
=
{
temperature
:
"
11c
"
,
"
time
"
:
"
11:00
"
temperature
:
'
11c
'
,
'
time
'
:
'
11:00
'
};
let
obj1
=
formBindingData
.
createFormBindingData
(
dataObj1
);
return
obj1
;
...
...
@@ -51,22 +51,22 @@ startAbility(want: Want, callback: AsyncCallback<void>): void
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.formstartability
"
,
abilityName
:
"
MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
''
,
bundleName
:
'
com.example.formstartability
'
,
abilityName
:
'
MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{}
}
}
;
this
.
context
.
startAbility
(
want
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
FormExtensionContext startAbility, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
console
.
log
(
`FormExtensionContext startAbility success`
);
}
})
})
;
```
## startAbility
...
...
@@ -95,18 +95,18 @@ startAbility(want: Want): Promise<void>
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.formstartability
"
,
abilityName
:
"
MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
deviceId
:
''
,
bundleName
:
'
com.example.formstartability
'
,
abilityName
:
'
MainAbility
'
,
action
:
'
action1
'
,
entities
:
[
'
entity1
'
],
type
:
'
MIMETYPE
'
,
uri
:
'
key={true,true,false}
'
,
parameters
:
{}
}
}
;
this
.
context
.
startAbility
(
want
).
then
(()
=>
{
console
.
info
(
"
StartAbility Success
"
);
console
.
info
(
'
StartAbility Success
'
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
StartAbility failed
"
);
console
.
info
(
'
StartAbility failed
'
);
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionCallbacks.md
浏览文件 @
b2011405
...
...
@@ -15,19 +15,19 @@
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
;
let
missionDeviceInfo
=
{
deviceId
:
"
123456
"
deviceId
:
'
123456
'
};
let
missionCallback
=
{
notifyMissionsChanged
:
function
(
deviceId
)
{
console
.
log
(
"
notifyMissionsChanged deviceId:
"
+
JSON
.
stringify
(
deviceId
));
console
.
log
(
'
notifyMissionsChanged deviceId:
'
+
JSON
.
stringify
(
deviceId
));
},
notifySnapshot
:
function
(
deviceId
,
mission
)
{
console
.
log
(
"
notifySnapshot deviceId:
"
+
JSON
.
stringify
(
deviceId
));
console
.
log
(
"
notifySnapshot mission:
"
+
JSON
.
stringify
(
mission
));
console
.
log
(
'
notifySnapshot deviceId:
'
+
JSON
.
stringify
(
deviceId
));
console
.
log
(
'
notifySnapshot mission:
'
+
JSON
.
stringify
(
mission
));
},
notifyNetDisconnect
:
function
(
deviceId
,
state
)
{
console
.
log
(
"
notifyNetDisconnect deviceId:
"
+
JSON
.
stringify
(
deviceId
));
console
.
log
(
"
notifyNetDisconnect state:
"
+
JSON
.
stringify
(
state
));
console
.
log
(
'
notifyNetDisconnect deviceId:
'
+
JSON
.
stringify
(
deviceId
));
console
.
log
(
'
notifyNetDisconnect state:
'
+
JSON
.
stringify
(
state
));
}
};
distributedMissionManager
.
registerMissionListener
(
missionDeviceInfo
,
missionCallback
);
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionDeviceInfo.md
浏览文件 @
b2011405
...
...
@@ -13,19 +13,19 @@
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
;
let
missionDeviceInfo
=
{
deviceId
:
"
123456
"
deviceId
:
'
123456
'
};
let
missionCallback
=
{
notifyMissionsChanged
:
function
(
deviceId
)
{
console
.
log
(
"
notifyMissionsChanged deviceId:
"
+
JSON
.
stringify
(
deviceId
));
console
.
log
(
'
notifyMissionsChanged deviceId:
'
+
JSON
.
stringify
(
deviceId
));
},
notifySnapshot
:
function
(
mission
,
deviceId
)
{
console
.
log
(
"
notifySnapshot mission:
"
+
JSON
.
stringify
(
mission
));
console
.
log
(
"
notifySnapshot deviceId:
"
+
JSON
.
stringify
(
deviceId
));
console
.
log
(
'
notifySnapshot mission:
'
+
JSON
.
stringify
(
mission
));
console
.
log
(
'
notifySnapshot deviceId:
'
+
JSON
.
stringify
(
deviceId
));
},
notifyNetDisconnect
:
function
(
mission
,
state
)
{
console
.
log
(
"
notifyNetDisconnect mission:
"
+
JSON
.
stringify
(
mission
));
console
.
log
(
"
notifyNetDisconnect state:
"
+
JSON
.
stringify
(
state
));
console
.
log
(
'
notifyNetDisconnect mission:
'
+
JSON
.
stringify
(
mission
));
console
.
log
(
'
notifyNetDisconnect state:
'
+
JSON
.
stringify
(
state
));
}
};
distributedMissionManager
.
registerMissionListener
(
missionDeviceInfo
,
missionCallback
);
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionInfo.md
浏览文件 @
b2011405
...
...
@@ -19,9 +19,9 @@
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfo
(
"
12345
"
,
1
,
(
error
,
data
)
=>
{
missionManager
.
getMissionInfo
(
'
12345
'
,
1
,
(
error
,
data
)
=>
{
console
.
info
(
'
getMissionInfo missionId is:
'
+
JSON
.
stringify
(
data
.
missionId
));
console
.
info
(
'
getMissionInfo runningState is:
'
+
JSON
.
stringify
(
data
.
runningState
));
console
.
info
(
'
getMissionInfo lockedState is:
'
+
JSON
.
stringify
(
data
.
lockedState
));
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md
浏览文件 @
b2011405
...
...
@@ -16,26 +16,26 @@
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
onMissionCreated mission:
"
+
JSON
.
stringify
(
mission
));
console
.
log
(
'
onMissionCreated mission:
'
+
JSON
.
stringify
(
mission
));
},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
onMissionDestroyed mission:
"
+
JSON
.
stringify
(
mission
));
console
.
log
(
'
onMissionDestroyed mission:
'
+
JSON
.
stringify
(
mission
));
},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
onMissionSnapshotChanged mission:
"
+
JSON
.
stringify
(
mission
));
console
.
log
(
'
onMissionSnapshotChanged mission:
'
+
JSON
.
stringify
(
mission
));
},
onMissionMovedToFront
:
function
(
mission
)
{
console
.
log
(
"
onMissionMovedToFront mission:
"
+
JSON
.
stringify
(
mission
));
console
.
log
(
'
onMissionMovedToFront mission:
'
+
JSON
.
stringify
(
mission
));
},
onMissionIconUpdated
:
function
(
mission
,
icon
)
{
console
.
log
(
"
onMissionIconUpdated mission:
"
+
JSON
.
stringify
(
mission
));
console
.
log
(
'
onMissionIconUpdated mission:
'
+
JSON
.
stringify
(
mission
));
},
onMissionClosed
:
function
(
mission
)
{
console
.
log
(
"
onMissionClosed mission:
"
+
JSON
.
stringify
(
mission
));
console
.
log
(
'
onMissionClosed mission:
'
+
JSON
.
stringify
(
mission
));
}
};
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionParameter.md
浏览文件 @
b2011405
...
...
@@ -15,14 +15,14 @@
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
;
let
missionParameter
=
{
deviceId
:
"
123456
"
,
deviceId
:
'
123456
'
,
fixConflict
:
true
,
tag
:
123
};
try
{
distributedMissionManager
.
startSyncRemoteMissions
(
missionParameter
,
(
err
,
data
)
=>
{
console
.
log
(
"
startSyncRemoteMissions, data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
startSyncRemoteMissions, data:
'
+
JSON
.
stringify
(
data
));
}
);
}
catch
(
err
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md
浏览文件 @
b2011405
...
...
@@ -24,15 +24,15 @@ import ElementName from '@ohos.bundle';
import
image
from
'
@ohos.multimedia.image
'
;
import
missionManager
from
'
@ohos.application.missionManager
'
;
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
console
.
log
(
'
getMissionInfos is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
size =
'
+
missions
.
length
);
console
.
log
(
'
missions =
'
+
JSON
.
stringify
(
missions
));
let
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
missionManager
.
getMissionSnapShot
(
''
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
'
getMissionSnapShot is called, error.code =
'
+
error
.
code
);
console
.
log
(
'
bundleName =
'
+
snapshot
.
ability
.
bundleName
);
})
;
})
;
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-processInformation.md
浏览文件 @
b2011405
...
...
@@ -14,7 +14,7 @@ ProcessInformation模块提供对进程运行信息进行查询的能力。
import
appManager
from
'
@ohos.app.ability.appManager
'
;
appManager
.
getRunningProcessInformation
((
error
,
data
)
=>
{
console
.
log
(
"
error:
"
+
error
.
code
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
error:
'
+
error
.
code
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md
浏览文件 @
b2011405
...
...
@@ -69,8 +69,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void;
```
ts
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
try
{
...
...
@@ -142,8 +142,8 @@ startAbility(want: Want, options?: StartOptions): Promise\<void>;
```
ts
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
let
options
=
{
windowMode
:
0
,
...
...
@@ -213,9 +213,9 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
options
=
{
windowMode
:
0
...
...
@@ -291,9 +291,9 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -368,9 +368,9 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -454,9 +454,9 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -519,9 +519,9 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -585,9 +585,9 @@ startServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -651,9 +651,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -722,9 +722,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -781,9 +781,9 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -844,9 +844,9 @@ stopServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -906,9 +906,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -974,9 +974,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
...
...
@@ -1119,14 +1119,14 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
```
ts
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
)
},
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
}
}
}
;
let
connection
=
null
;
try
{
...
...
@@ -1179,9 +1179,9 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -1359,10 +1359,10 @@ startAbilityByCall(want: Want): Promise<Caller>;
// 后台启动Ability,不配置parameters
let
wantBackground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
};
try
{
...
...
@@ -1388,14 +1388,14 @@ startAbilityByCall(want: Want): Promise<Caller>;
```
ts
let
caller
=
undefined
;
// 前台启动Ability,将parameters中的
"ohos.aafwk.param.callAbilityToForeground"
配置为true
// 前台启动Ability,将parameters中的
'ohos.aafwk.param.callAbilityToForeground'
配置为true
let
wantForeground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
,
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
,
parameters
:
{
"
ohos.aafwk.param.callAbilityToForeground
"
:
true
'
ohos.aafwk.param.callAbilityToForeground
'
:
true
}
};
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md
浏览文件 @
b2011405
...
...
@@ -19,13 +19,13 @@
**示例:**
```
ts
import
AbilityDelegatorRegistry
from
"
@ohos.application.abilityDelegatorRegistry
"
;
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
;
let
abilityDelegator
;
let
cmd
=
"
cmd
"
;
let
cmd
=
'
cmd
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
executeShellCommand callback, failed:
"
,
err
);
console
.
info
(
"
executeShellCommand callback, success:
"
,
data
);
console
.
info
(
'
executeShellCommand callback, failed:
'
,
err
);
console
.
info
(
'
executeShellCommand callback, success:
'
,
data
);
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
浏览文件 @
b2011405
...
...
@@ -67,8 +67,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void;
```
ts
var
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
try
{
...
...
@@ -139,9 +139,9 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
options
=
{
windowMode
:
0
...
...
@@ -219,8 +219,8 @@ startAbility(want: Want, options?: StartOptions): Promise<void>;
```
ts
var
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
var
options
=
{
windowMode
:
0
,
...
...
@@ -296,9 +296,9 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>):
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -310,7 +310,7 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>):
return
;
}
// 执行正常业务
console
.
log
(
"
startAbilityForResult succeed, result.resultCode =
"
+
console
.
log
(
'
startAbilityForResult succeed, result.resultCode =
'
+
result
.
resultCode
)
});
}
catch
(
paramError
)
{
...
...
@@ -372,9 +372,9 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
options
=
{
windowMode
:
0
,
...
...
@@ -389,7 +389,7 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
return
;
}
// 执行正常业务
console
.
log
(
"
startAbilityForResult succeed, result.resultCode =
"
+
console
.
log
(
'
startAbilityForResult succeed, result.resultCode =
'
+
result
.
resultCode
)
});
}
catch
(
paramError
)
{
...
...
@@ -458,8 +458,8 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes
```
ts
var
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
var
options
=
{
windowMode
:
0
,
...
...
@@ -469,7 +469,7 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes
this
.
context
.
startAbilityForResult
(
want
,
options
)
.
then
((
result
)
=>
{
// 执行正常业务
console
.
log
(
"
startAbilityForResult succeed, result.resultCode =
"
+
result
.
resultCode
);
console
.
log
(
'
startAbilityForResult succeed, result.resultCode =
'
+
result
.
resultCode
);
})
.
catch
((
error
)
=>
{
// 处理业务逻辑错误
...
...
@@ -532,9 +532,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
...
...
@@ -547,7 +547,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC
return
;
}
// 执行正常业务
console
.
log
(
"
startAbilityForResultWithAccount succeed, result.resultCode =
"
+
console
.
log
(
'
startAbilityForResultWithAccount succeed, result.resultCode =
'
+
result
.
resultCode
)
});
}
catch
(
paramError
)
{
...
...
@@ -608,9 +608,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
var
options
=
{
...
...
@@ -626,7 +626,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
return
;
}
// 执行正常业务
console
.
log
(
"
startAbilityForResultWithAccount succeed, result.resultCode =
"
+
console
.
log
(
'
startAbilityForResultWithAccount succeed, result.resultCode =
'
+
result
.
resultCode
)
});
}
catch
(
paramError
)
{
...
...
@@ -692,9 +692,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
var
options
=
{
...
...
@@ -705,7 +705,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
this
.
context
.
startAbilityForResultWithAccount
(
want
,
accountId
,
options
)
.
then
((
result
)
=>
{
// 执行正常业务
console
.
log
(
"
startAbilityForResultWithAccount succeed, result.resultCode =
"
+
console
.
log
(
'
startAbilityForResultWithAccount succeed, result.resultCode =
'
+
result
.
resultCode
)
})
.
catch
((
error
)
=>
{
...
...
@@ -757,9 +757,9 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -817,9 +817,9 @@ startServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -878,9 +878,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
...
...
@@ -943,9 +943,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
...
...
@@ -1001,9 +1001,9 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -1058,9 +1058,9 @@ stopServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
try
{
...
...
@@ -1120,9 +1120,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
...
...
@@ -1182,9 +1182,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
...
...
@@ -1316,8 +1316,8 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi
```
ts
var
want
=
{
bundleName
:
"
com.extreme.myapplication
"
,
abilityName
:
"
SecondAbility
"
bundleName
:
'
com.extreme.myapplication
'
,
abilityName
:
'
SecondAbility
'
}
var
resultCode
=
100
;
// 返回给接口调用方AbilityResult信息
...
...
@@ -1381,8 +1381,8 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>;
```
ts
var
want
=
{
bundleName
:
"
com.extreme.myapplication
"
,
abilityName
:
"
SecondAbility
"
bundleName
:
'
com.extreme.myapplication
'
,
abilityName
:
'
SecondAbility
'
}
var
resultCode
=
100
;
// 返回给接口调用方AbilityResult信息
...
...
@@ -1446,9 +1446,9 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
...
...
@@ -1510,9 +1510,9 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
var
options
=
{
...
...
@@ -1674,10 +1674,10 @@ startAbilityByCall(want: Want): Promise<Caller>;
// 后台启动Ability,不配置parameters
var
wantBackground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
};
try
{
...
...
@@ -1703,14 +1703,14 @@ startAbilityByCall(want: Want): Promise<Caller>;
```
ts
var
caller
=
undefined
;
// 前台启动Ability,将parameters中的
"ohos.aafwk.param.callAbilityToForeground"
配置为true
// 前台启动Ability,将parameters中的
'ohos.aafwk.param.callAbilityToForeground'
配置为true
var
wantForeground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
,
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
MainAbility
'
,
deviceId
:
''
,
parameters
:
{
"
ohos.aafwk.param.callAbilityToForeground
"
:
true
'
ohos.aafwk.param.callAbilityToForeground
'
:
true
}
};
...
...
@@ -1781,9 +1781,9 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
...
...
@@ -1856,9 +1856,9 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
var
options
=
{
...
...
@@ -1933,9 +1933,9 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
deviceId
:
''
,
bundleName
:
'
com.extreme.test
'
,
abilityName
:
'
MainAbility
'
};
var
accountId
=
100
;
var
options
=
{
...
...
@@ -2037,7 +2037,7 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void;
**示例:**
```
ts
this
.
context
.
setMissionLabel
(
"
test
"
,(
result
)
=>
{
this
.
context
.
setMissionLabel
(
'
test
'
,(
result
)
=>
{
console
.
log
(
'
requestPermissionsFromUserresult:
'
+
JSON
.
stringify
(
result
));
});
```
...
...
@@ -2066,7 +2066,7 @@ setMissionLabel(label: string): Promise<void>;
**示例:**
```
ts
this
.
context
.
setMissionLabel
(
"
test
"
).
then
(()
=>
{
this
.
context
.
setMissionLabel
(
'
test
'
).
then
(()
=>
{
console
.
log
(
'
success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
failed:
'
+
JSON
.
stringify
(
error
));
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md
浏览文件 @
b2011405
...
...
@@ -19,7 +19,7 @@ WindowExtensionContext模块提供[WindowExtensionAbility](js-apis-application-w
```
ts
import
WindowExtensionAbility
from
'
@ohos.application.WindowExtensionAbility
'
;
let
context
=
undefined
;
let
context
;
class
WindowExtAbility
extends
WindowExtensionAbility
{
onConnect
()
{
context
=
this
.
context
;
// 获取WindowExtensionContext
...
...
@@ -47,8 +47,8 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
```
ts
var
want
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
MainAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
MainAbility
'
};
var
options
=
{
windowMode
:
102
...
...
@@ -97,8 +97,8 @@ startAbility(want: Want, options?: StartOptions): Promise\<void>
```
ts
var
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MainAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MainAbility
'
};
var
options
=
{
windowMode
:
102
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录