Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
e53420cc
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看板
提交
e53420cc
编写于
2月 16, 2023
作者:
M
mingxihua
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mingxihua@huawei.com.cn
Signed-off-by:
N
mingxihua
<
mingxihua@huawei.com
>
上级
60515c3b
变更
87
隐藏空白更改
内联
并排
Showing
87 changed file
with
1800 addition
and
1800 deletion
+1800
-1800
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
+110
-110
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
+9
-9
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
+4
-4
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-dataUriUtils.md
...on-dev/reference/apis/js-apis-app-ability-dataUriUtils.md
+13
-13
zh-cn/application-dev/reference/apis/js-apis-app-ability-dialogRequest.md
...n-dev/reference/apis/js-apis-app-ability-dialogRequest.md
+7
-7
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
+14
-14
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
...-dev/reference/apis/js-apis-app-ability-missionManager.md
+77
-77
zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md
...dev/reference/apis/js-apis-app-ability-quickFixManager.md
+19
-19
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
+36
-36
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
...ation-dev/reference/apis/js-apis-app-ability-wantAgent.md
+17
-17
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
+11
-11
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-formInfo.md
...plication-dev/reference/apis/js-apis-app-form-formInfo.md
+10
-10
zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md
...ation-dev/reference/apis/js-apis-app-form-formProvider.md
+32
-32
zh-cn/application-dev/reference/apis/js-apis-application-ability.md
...ication-dev/reference/apis/js-apis-application-ability.md
+27
-27
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
+19
-19
zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md
...-dev/reference/apis/js-apis-application-abilityManager.md
+7
-7
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
+13
-13
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
+6
-6
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
+4
-4
zh-cn/application-dev/reference/apis/js-apis-application-formHost.md
...cation-dev/reference/apis/js-apis-application-formHost.md
+53
-53
zh-cn/application-dev/reference/apis/js-apis-application-formInfo.md
...cation-dev/reference/apis/js-apis-application-formInfo.md
+7
-7
zh-cn/application-dev/reference/apis/js-apis-application-formProvider.md
...on-dev/reference/apis/js-apis-application-formProvider.md
+6
-6
zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md
...-dev/reference/apis/js-apis-application-missionManager.md
+139
-139
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
+118
-118
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityOperation.md
...erence/apis/js-apis-inner-ability-dataAbilityOperation.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md
...reference/apis/js-apis-inner-ability-dataAbilityResult.md
+7
-7
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
+16
-16
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
+91
-91
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md
...eference/apis/js-apis-inner-application-abilityMonitor.md
+4
-4
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
+3
-3
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
+56
-56
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md
...pis/js-apis-inner-application-applicationStateObserver.md
+1
-1
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
+5
-5
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueDeviceInfo.md
...ence/apis/js-apis-inner-application-continueDeviceInfo.md
+5
-5
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
+13
-13
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
+14
-14
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
+5
-5
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md
...ference/apis/js-apis-inner-application-missionListener.md
+9
-9
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
+10
-10
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
+63
-63
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
+104
-104
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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -16,7 +16,7 @@ AbilityContext模块提供允许访问特定Ability的资源的能力,包括
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
let
context
=
undefined
;
let
context
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
)
{
context
=
this
.
context
;
...
...
@@ -66,8 +66,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void;
```
ts
let
want
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
MyAbility
'
};
try
{
...
...
@@ -122,9 +122,9 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
windowMode
:
0
...
...
@@ -186,8 +186,8 @@ startAbility(want: Want, options?: StartOptions): Promise<void>;
```
ts
let
want
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
MyAbility
'
};
let
options
=
{
windowMode
:
0
,
...
...
@@ -247,9 +247,9 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>):
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
...
...
@@ -261,8 +261,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
)
{
// 处理入参错误异常
...
...
@@ -307,9 +307,9 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
windowMode
:
0
,
...
...
@@ -324,8 +324,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
)
{
// 处理入参错误异常
...
...
@@ -377,8 +377,8 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes
```
ts
let
want
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
MyAbility
'
};
let
options
=
{
windowMode
:
0
,
...
...
@@ -388,7 +388,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
)
=>
{
// 处理业务逻辑错误
...
...
@@ -439,9 +439,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
...
...
@@ -454,8 +454,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
)
{
// 处理入参错误异常
...
...
@@ -503,9 +503,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -521,8 +521,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
)
{
// 处理入参错误异常
...
...
@@ -575,9 +575,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -588,8 +588,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
)
=>
{
// 处理业务逻辑错误
...
...
@@ -631,9 +631,9 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
...
...
@@ -682,9 +682,9 @@ startServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
...
...
@@ -737,9 +737,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
...
...
@@ -792,9 +792,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
...
...
@@ -844,20 +844,20 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
this
.
context
.
startAbility
(
want
,
(
error
)
=>
{
if
(
error
.
code
!=
0
)
{
console
.
log
(
"
start ability fail, err:
"
+
JSON
.
stringify
(
err
));
if
(
error
.
code
!=
=
0
)
{
console
.
log
(
'
start ability fail, err:
'
+
JSON
.
stringify
(
err
));
}
})
this
.
context
.
stopServiceExtensionAbility
(
want
,
(
error
)
=>
{
if
(
error
.
code
!=
0
)
{
if
(
error
.
code
!=
=
0
)
{
// 处理业务逻辑错误
console
.
log
(
'
stopServiceExtensionAbility failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
...
...
@@ -901,15 +901,15 @@ stopServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
this
.
context
.
startAbility
(
want
,
(
error
)
=>
{
if
(
error
.
code
!=
0
)
{
console
.
log
(
"
start ability fail, err:
"
+
JSON
.
stringify
(
err
));
if
(
error
.
code
!=
=
0
)
{
console
.
log
(
'
start ability fail, err:
'
+
JSON
.
stringify
(
err
));
}
})
...
...
@@ -962,16 +962,16 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
try
{
this
.
context
.
startAbilityWithAccount
(
want
,
accountId
,
(
error
)
=>
{
if
(
error
.
code
!=
0
)
{
console
.
log
(
"
start ability fail, err:
"
+
JSON
.
stringify
(
err
));
if
(
error
.
code
!=
=
0
)
{
console
.
log
(
'
start ability fail, err:
'
+
JSON
.
stringify
(
err
));
}
})
...
...
@@ -1023,16 +1023,16 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
try
{
this
.
context
.
startAbilityWithAccount
(
want
,
accountId
,
(
error
)
=>
{
if
(
error
.
code
!=
0
)
{
console
.
log
(
"
start ability fail, err:
"
+
JSON
.
stringify
(
err
));
if
(
error
.
code
!=
=
0
)
{
console
.
log
(
'
start ability fail, err:
'
+
JSON
.
stringify
(
err
));
}
})
...
...
@@ -1154,15 +1154,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
)
=>
{
...
...
@@ -1217,15 +1217,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
)
...
...
@@ -1280,15 +1280,15 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
)
},
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
}
}
}
;
let
connection
=
null
;
try
{
...
...
@@ -1339,16 +1339,16 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
)
},
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
}
}
}
;
let
connection
=
null
;
try
{
...
...
@@ -1491,14 +1491,14 @@ startAbilityByCall(want: Want): Promise<Caller>;
后台启动:
```
ts
let
caller
=
undefined
;
let
caller
;
// 后台启动Ability,不配置parameters
let
wantBackground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
EntryAbility
'
,
deviceId
:
''
};
try
{
...
...
@@ -1522,16 +1522,16 @@ startAbilityByCall(want: Want): Promise<Caller>;
前台启动:
```
ts
let
caller
=
undefined
;
let
caller
;
// 前台启动Ability,将parameters中的
"ohos.aafwk.param.callAbilityToForeground"
配置为true
// 前台启动Ability,将parameters中的
'ohos.aafwk.param.callAbilityToForeground'
配置为true
let
wantForeground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
""
,
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
EntryAbility
'
,
deviceId
:
''
,
parameters
:
{
"
ohos.aafwk.param.callAbilityToForeground
"
:
true
'
ohos.aafwk.param.callAbilityToForeground
'
:
true
}
};
...
...
@@ -1590,9 +1590,9 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
...
...
@@ -1653,9 +1653,9 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -1718,9 +1718,9 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -1763,7 +1763,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
));
});
```
...
...
@@ -1792,7 +1792,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
));
...
...
@@ -1832,7 +1832,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
);
...
...
@@ -1879,7 +1879,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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -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
));
});
```
...
...
@@ -146,7 +146,7 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
```
...
...
@@ -182,19 +182,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
));
}
);
```
...
...
@@ -236,30 +236,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
));
});
```
...
...
@@ -288,29 +288,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
));
}
);
```
...
...
@@ -345,29 +345,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=======================>
'
);
});
```
...
...
@@ -390,7 +390,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
));
});
```
...
...
@@ -413,7 +413,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
));
});
```
...
...
@@ -436,7 +436,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
));
});
```
...
...
@@ -459,7 +459,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
));
});
```
...
...
@@ -481,9 +481,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
));
});
```
...
...
@@ -507,7 +507,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
));
}
)
```
...
...
@@ -531,7 +531,7 @@ terminateSelf(): Promise\<void>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
terminateSelf
().
then
((
data
)
=>
{
console
.
info
(
"
==========================>terminateSelf=======================>
"
);
console
.
info
(
'
==========================>terminateSelf=======================>
'
);
});
```
...
...
@@ -578,9 +578,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
,
...
...
@@ -614,15 +614,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
,
...
...
@@ -632,8 +632,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
));
});
```
...
...
@@ -666,15 +666,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
,
...
...
@@ -686,7 +686,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
);
});
```
...
...
@@ -709,7 +709,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
));
});
```
...
...
@@ -731,7 +731,7 @@ getWindow(): Promise\<window.Window>;
```
ts
featureAbility
.
getWindow
().
then
((
data
)
=>
{
console
.
info
(
"
getWindow data:
"
+
typeof
(
data
));
console
.
info
(
'
getWindow data:
'
+
typeof
(
data
));
});
```
...
...
@@ -772,9 +772,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
浏览文件 @
e53420cc
...
...
@@ -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
:
"
EntryAbility
"
,
uri
:
""
deviceId
:
''
,
bundleName
:
'
com.example.Data
'
,
abilityName
:
'
EntryAbility
'
,
uri
:
''
},
},
(
error
,
result
)
=>
{
console
.
log
(
'
particleAbility startAbility errCode:
'
+
error
+
'
result:
'
+
result
)
console
.
error
(
'
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
:
"
EntryAbility
"
,
uri
:
""
deviceId
:
''
,
bundleName
:
'
com.example.Data
'
,
abilityName
:
'
EntryAbility
'
,
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
'
);
});
```
...
...
@@ -194,10 +194,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
)
;
```
...
...
@@ -228,17 +228,17 @@ import wantAgent from '@ohos.app.ability.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
:
"
EntryAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
}
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
...
...
@@ -248,8 +248,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
,
...
...
@@ -298,8 +298,8 @@ import wantAgent from '@ohos.app.ability.wantAgent';
let
wantAgentInfo
=
{
wants
:
[
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
}
],
operationType
:
wantAgent
.
OperationType
.
START_ABILITY
,
...
...
@@ -309,8 +309,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
,
...
...
@@ -322,9 +322,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
));
});
});
...
...
@@ -351,9 +351,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
'
);
}
}
...
...
@@ -381,9 +381,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
));
});
```
...
...
@@ -413,25 +413,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
,
...
...
@@ -441,9 +441,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
)
;
});
```
...
...
@@ -472,17 +472,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
,
...
...
@@ -492,8 +492,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
));
});
```
...
...
@@ -523,17 +523,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
,
...
...
@@ -543,9 +543,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
浏览文件 @
e53420cc
...
...
@@ -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.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
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
浏览文件 @
e53420cc
...
...
@@ -49,16 +49,16 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry
let
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
let
want
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
abilityDelegator
.
startAbility
(
want
,
(
err
)
=>
{
if
(
!
err
||
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
));
}
})
})
;
```
## AbilityDelegatorRegistry.getArguments
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -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
&&
error
.
code
!==
0
)
{
console
.
log
(
"
unregisterAbilityLifecycleCallback fail, error:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
'
unregisterAbilityLifecycleCallback fail, 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
浏览文件 @
e53420cc
...
...
@@ -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
&&
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
&&
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
&&
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
&&
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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -41,9 +41,9 @@ import appManager from '@ohos.app.ability.appManager';
appManager
.
isRunningInStabilityTest
((
err
,
flag
)
=>
{
if
(
err
&&
err
.
code
!==
0
)
{
console
.
log
(
"
isRunningInStabilityTest fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isRunningInStabilityTest fail, 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
&&
err
.
code
!==
0
)
{
console
.
log
(
"
isRamConstrainedDevice fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
isRamConstrainedDevice fail, 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
&&
err
.
code
!==
0
)
{
console
.
log
(
"
getAppMemorySize fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getAppMemorySize fail, 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
&&
err
.
code
!==
0
)
{
console
.
log
(
"
getRunningProcessInformation fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
getRunningProcessInformation fail, 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
&&
err
.
code
!==
0
)
{
console
.
log
(
"
unregisterApplicationStateObserverCallback fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
unregisterApplicationStateObserverCallback fail, 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 fail, err:
"
+
JSON
.
stringify
(
err
));
console
.
log
(
'
unregisterApplicationStateObserver fail, 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
&&
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
&&
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
&&
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
&&
err
.
code
!==
0
)
{
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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -10,7 +10,7 @@ Common模块将二级模块API组织在一起方便开发者进行导出。
## 导入模块
```
ts
import
common
from
'
@ohos.app.ability.common
'
import
common
from
'
@ohos.app.ability.common
'
;
```
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
...
...
@@ -32,7 +32,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
浏览文件 @
e53420cc
...
...
@@ -28,7 +28,7 @@ export default class EntryAbility extends UIAbility {
onCreate
(
want
,
launchParam
)
{
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
;
let
direction
=
config
.
direction
;
...
...
@@ -39,10 +39,10 @@ export default class EntryAbility extends UIAbility {
};
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
浏览文件 @
e53420cc
...
...
@@ -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-dataUriUtils.md
浏览文件 @
e53420cc
...
...
@@ -36,10 +36,10 @@ getId(uri: string): number
```
ts
try
{
let
id
=
dataUriUtils
.
getId
(
"
com.example.dataUriUtils/1221
"
)
console
.
info
(
'
get id:
'
+
id
)
let
id
=
dataUriUtils
.
getId
(
'
com.example.dataUriUtils/1221
'
);
console
.
info
(
'
get id:
'
+
id
)
;
}
catch
(
err
)
{
console
.
error
(
'
get id err ,check the uri
'
+
err
)
console
.
error
(
'
get id err ,check the uri
'
+
err
)
;
}
```
...
...
@@ -72,12 +72,12 @@ attachId(uri: string, id: number): string
let
id
=
1122
;
try
{
let
uri
=
dataUriUtils
.
attachId
(
"
com.example.dataUriUtils
"
,
'
com.example.dataUriUtils
'
,
id
,
)
console
.
info
(
'
attachId the uri is:
'
+
uri
)
)
;
console
.
info
(
'
attachId the uri is:
'
+
uri
)
;
}
catch
(
err
)
{
console
.
error
(
'
get id err ,check the uri
'
+
err
)
console
.
error
(
'
get id err ,check the uri
'
+
err
)
;
}
```
...
...
@@ -108,10 +108,10 @@ deleteId(uri: string): string
```
ts
try
{
let
uri
=
dataUriUtils
.
deleteId
(
"
com.example.dataUriUtils/1221
"
)
console
.
info
(
'
delete id with the uri is:
'
+
uri
)
let
uri
=
dataUriUtils
.
deleteId
(
'
com.example.dataUriUtils/1221
'
);
console
.
info
(
'
delete id with the uri is:
'
+
uri
)
;
}
catch
(
err
)
{
console
.
error
(
'
delete uri err, check the input uri
'
+
err
)
console
.
error
(
'
delete uri err, check the input uri
'
+
err
)
;
}
```
...
...
@@ -146,11 +146,11 @@ updateId(uri: string, id: number): string
try
{
let
id
=
1122
;
let
uri
=
dataUriUtils
.
updateId
(
"
com.example.dataUriUtils/1221
"
,
'
com.example.dataUriUtils/1221
'
,
id
)
)
;
}
catch
(
err
)
{
console
.
error
(
'
delete uri err, check the input uri
'
+
err
)
console
.
error
(
'
delete uri err, check the input uri
'
+
err
)
;
}
```
zh-cn/application-dev/reference/apis/js-apis-app-ability-dialogRequest.md
浏览文件 @
e53420cc
...
...
@@ -49,9 +49,9 @@ getRequestInfo(want: Want): RequestInfo
onRequest
(
want
,
startId
)
{
console
.
info
(
TAG
,
`onRequest, want:
${
want
.
abilityName
}
`
);
try
{
var
requestInfo
=
dialogRequest
.
getRequestInfo
(
want
)
var
requestInfo
=
dialogRequest
.
getRequestInfo
(
want
)
;
}
catch
(
err
)
{
console
.
error
(
'
getRequestInfo err=
'
+
JSON
.
stringify
(
err
))
console
.
error
(
'
getRequestInfo err=
'
+
JSON
.
stringify
(
err
))
;
}
}
...
...
@@ -104,9 +104,9 @@ getRequestCallback(want: Want): RequestCallback
onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try {
var requestCallback = dialogRequest.getRequestCallback(want)
var requestCallback = dialogRequest.getRequestCallback(want)
;
} catch(err) {
console.error('getRequestInfo err= ' + JSON.stringify(err))
console.error('getRequestInfo err= ' + JSON.stringify(err))
;
}
}
...
...
@@ -145,7 +145,7 @@ getRequestCallback(want: Want): RequestCallback
onRequest(want, startId) {
console.info(TAG, `onRequest, want: ${want.abilityName}`);
try {
var requestInfo = dialogRequest.getRequestInfo(want)
var requestInfo = dialogRequest.getRequestInfo(want)
;
window.bindDialogTarget(requestInfo, () => {
console.info('Dialog Window Need Destroy.');
}, (err) => {
...
...
@@ -156,7 +156,7 @@ getRequestCallback(want: Want): RequestCallback
console.info('Succeeded in binding dialog target.');
});
} catch(err) {
console.error('getRequestInfo err= ' + JSON.stringify(err))
console.error('getRequestInfo err= ' + JSON.stringify(err))
;
}
}
...
...
@@ -243,7 +243,7 @@ setRequestResult(result: RequestResult): void;
};
requestCallback
.
setRequestResult
(
myResult
);
}
catch
(
err
)
{
console
.
error
(
'
getRequestInfo err=
'
+
JSON
.
stringify
(
err
))
console
.
error
(
'
getRequestInfo err=
'
+
JSON
.
stringify
(
err
))
;
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
浏览文件 @
e53420cc
...
...
@@ -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
UIAbility
from
"
@ohos.app.ability.Ability
"
;
import
UIAbility
from
'
@ohos.app.ability.Ability
'
;
let
callbackId
;
export
default
class
MyAbility
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
));
}
}
// 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
浏览文件 @
e53420cc
...
...
@@ -8,12 +8,12 @@ ErrorManager模块提供对错误观察器的注册和注销的能力。使用
## 导入模块
```
ts
import
errorManager
from
'
@ohos.app.ability.errorManager
'
import
errorManager
from
'
@ohos.app.ability.errorManager
'
;
```
## ErrorManager.on
on(type:
"error"
, observer: ErrorObserver): number;
on(type:
'error'
, observer: ErrorObserver): number;
注册错误观测器。
...
...
@@ -23,7 +23,7 @@ on(type: "error", observer: ErrorObserver): number;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 填写
"error"
,表示错误观察器。 |
| type | string | 是 | 填写
'error'
,表示错误观察器。 |
| observer |
[
ErrorObserver
](
./js-apis-inner-application-errorObserver.md
)
| 是 | 错误观察器。 |
**返回值:**
...
...
@@ -37,20 +37,20 @@ on(type: "error", observer: ErrorObserver): number;
```
ts
let
observer
=
{
onUnhandledException
(
errorMsg
)
{
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
)
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
)
;
}
}
let
observerId
=
-
1
;
try
{
observerId
=
errorManager
.
on
(
"
error
"
,
observer
);
observerId
=
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;
注销错误观测器。
...
...
@@ -60,7 +60,7 @@ off(type: "error", observerId: number, callback: AsyncCallback\<void>): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 填写
"error"
,表示错误观察器。 |
| type | string | 是 | 填写
'error'
,表示错误观察器。 |
| observerId | number | 是 | 由on方法返回的观察器的index值。 |
| callback | AsyncCallback
\<
void> | 是 | 表示指定的回调方法。 |
...
...
@@ -75,15 +75,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>;
注销错误观测器。
...
...
@@ -93,7 +93,7 @@ off(type: "error", observerId: number): Promise\<void>;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 填写
"error"
,表示错误观察器。 |
| type | string | 是 | 填写
'error'
,表示错误观察器。 |
| observerId | number | 是 | 由on方法返回的观察器的index值。 |
**返回值:**
...
...
@@ -107,7 +107,7 @@ off(type: "error", observerId: number): Promise\<void>;
```
ts
let
observerId
=
100
;
try
{
errorManager
.
off
(
"
error
"
,
observerId
)
errorManager
.
off
(
'
error
'
,
observerId
)
.
then
((
data
)
=>
{
console
.
log
(
'
----------- unregisterErrorObserver success ----------
'
,
data
);
})
...
...
@@ -115,7 +115,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
浏览文件 @
e53420cc
...
...
@@ -18,7 +18,7 @@ ohos.permission.MANAGE_MISSIONS
## missionManager.on
on(type:
"mission"
, listener: MissionListener): number;
on(type:
'mission'
, listener: MissionListener): number;
注册系统任务状态监听器。
...
...
@@ -47,52 +47,52 @@ import missionManager from '@ohos.app.ability.missionManager';
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
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-------
'
)}
};
let
listenerId
=
-
1
;
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
"
[Demo] EntryAbility onCreate
"
);
console
.
log
(
'
[Demo] EntryAbility onCreate
'
);
globalThis
.
abilityWant
=
want
;
globalThis
.
context
=
this
.
context
;
}
onDestroy
()
{
try
{
if
(
listenerId
!=
-
1
)
{
missionManager
.
off
(
"
mission
"
,
listenerId
).
catch
(
function
(
err
)
{
if
(
listenerId
!=
=
-
1
)
{
missionManager
.
off
(
'
mission
'
,
listenerId
).
catch
(
function
(
err
)
{
console
.
log
(
err
);
});
}
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
console
.
log
(
"
[Demo] EntryAbility onDestroy
"
)
console
.
log
(
'
[Demo] EntryAbility onDestroy
'
);
}
onWindowStageCreate
(
windowStage
)
{
// Main window is created, set main page for this ability
console
.
log
(
"
[Demo] EntryAbility onWindowStageCreate
"
)
console
.
log
(
'
[Demo] EntryAbility onWindowStageCreate
'
);
try
{
listenerId
=
missionManager
.
on
(
"
mission
"
,
listener
);
listenerId
=
missionManager
.
on
(
'
mission
'
,
listener
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
windowStage
.
loadContent
(
"
pages/index
"
,
(
err
,
data
)
=>
{
windowStage
.
loadContent
(
'
pages/index
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
))
;
});
if
(
globalThis
.
flag
)
{
...
...
@@ -105,7 +105,7 @@ export default class EntryAbility extends UIAbility {
## missionManager.off
off(type:
"mission"
, listenerId: number, callback: AsyncCallback
<
void
>
): void;
off(type:
'mission'
, listenerId: number, callback: AsyncCallback
<
void
>
): void;
解注册任务状态监听器。
...
...
@@ -129,52 +129,52 @@ import missionManager from '@ohos.app.ability.missionManager';
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
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-------
'
)}
};
let
listenerId
=
-
1
;
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
"
[Demo] EntryAbility onCreate
"
)
console
.
log
(
'
[Demo] EntryAbility onCreate
'
);
globalThis
.
abilityWant
=
want
;
globalThis
.
context
=
this
.
context
;
}
onDestroy
()
{
try
{
if
(
listenerId
!=
-
1
)
{
missionManager
.
off
(
"
mission
"
,
listenerId
,
(
err
)
=>
{
if
(
listenerId
!=
=
-
1
)
{
missionManager
.
off
(
'
mission
'
,
listenerId
,
(
err
)
=>
{
console
.
log
(
err
);
});
}
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
console
.
log
(
"
[Demo] EntryAbility onDestroy
"
)
console
.
log
(
'
[Demo] EntryAbility onDestroy
'
);
}
onWindowStageCreate
(
windowStage
)
{
// Main window is created, set main page for this ability
console
.
log
(
"
[Demo] EntryAbility onWindowStageCreate
"
)
console
.
log
(
'
[Demo] EntryAbility onWindowStageCreate
'
);
try
{
listenerId
=
missionManager
.
on
(
"
mission
"
,
listener
);
listenerId
=
missionManager
.
on
(
'
mission
'
,
listener
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
windowStage
.
loadContent
(
"
pages/index
"
,
(
err
,
data
)
=>
{
windowStage
.
loadContent
(
'
pages/index
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
))
;
});
if
(
globalThis
.
flag
)
{
...
...
@@ -187,7 +187,7 @@ export default class EntryAbility extends UIAbility {
## missionManager.off
off(type:
"mission"
, listenerId: number): Promise
<
void
>
;
off(type:
'mission'
, listenerId: number): Promise
<
void
>
;
解注册任务状态监听,以promise方式返回执行结果。
...
...
@@ -216,52 +216,52 @@ import missionManager from '@ohos.app.ability.missionManager';
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
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-------
'
)}
};
let
listenerId
=
-
1
;
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
"
[Demo] EntryAbility onCreate
"
)
console
.
log
(
'
[Demo] EntryAbility onCreate
'
);
globalThis
.
abilityWant
=
want
;
globalThis
.
context
=
this
.
context
;
}
onDestroy
()
{
try
{
if
(
listenerId
!=
-
1
)
{
missionManager
.
off
(
"
mission
"
,
listenerId
).
catch
(
function
(
err
)
{
if
(
listenerId
!=
=
-
1
)
{
missionManager
.
off
(
'
mission
'
,
listenerId
).
catch
(
function
(
err
)
{
console
.
log
(
err
);
});
}
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
console
.
log
(
"
[Demo] EntryAbility onDestroy
"
)
console
.
log
(
'
[Demo] EntryAbility onDestroy
'
);
}
onWindowStageCreate
(
windowStage
)
{
// Main window is created, set main page for this ability
console
.
log
(
"
[Demo] EntryAbility onWindowStageCreate
"
)
console
.
log
(
'
[Demo] EntryAbility onWindowStageCreate
'
);
try
{
listenerId
=
missionManager
.
on
(
"
mission
"
,
listener
);
listenerId
=
missionManager
.
on
(
'
mission
'
,
listener
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
windowStage
.
loadContent
(
"
pages/index
"
,
(
err
,
data
)
=>
{
windowStage
.
loadContent
(
'
pages/index
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
))
console
.
info
(
'
Succeeded in loading the content. Data:
'
+
JSON
.
stringify
(
data
))
;
});
if
(
globalThis
.
flag
)
{
...
...
@@ -299,26 +299,26 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
let
testMissionId
=
1
;
try
{
let
allMissions
=
await
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
let
allMissions
=
await
missionManager
.
getMissionInfos
(
''
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
if
(
allMissions
&&
allMissions
.
length
>
0
)
{
testMissionId
=
allMissions
[
0
].
missionId
;
}
missionManager
.
getMissionInfo
(
""
,
testMissionId
,
(
error
,
mission
)
=>
{
missionManager
.
getMissionInfo
(
''
,
testMissionId
,
(
error
,
mission
)
=>
{
if
(
error
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
console
.
log
(
'
getMissionInfo failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
else
{
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
);
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
);
}
```
...
...
@@ -355,7 +355,7 @@ import missionManager from '@ohos.app.ability.missionManager';
let
testMissionId
=
1
;
try
{
missionManager
.
getMissionInfo
(
""
,
testMissionId
).
then
((
data
)
=>
{
missionManager
.
getMissionInfo
(
''
,
testMissionId
).
then
((
data
)
=>
{
console
.
info
(
'
getMissionInfo successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
getMissionInfo failed. Cause:
'
+
error
.
message
);
...
...
@@ -391,17 +391,17 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Arr
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
,
(
error
,
missions
)
=>
{
missionManager
.
getMissionInfos
(
''
,
10
,
(
error
,
missions
)
=>
{
if
(
error
)
{
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
));
}
else
{
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
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
);
}
```
...
...
@@ -437,7 +437,7 @@ getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionIn
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfos
(
""
,
10
).
then
((
data
)
=>
{
missionManager
.
getMissionInfos
(
''
,
10
).
then
((
data
)
=>
{
console
.
info
(
'
getMissionInfos successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
getMissionInfos failed. Cause:
'
+
error
.
message
);
...
...
@@ -473,7 +473,7 @@ import missionManager from '@ohos.app.ability.missionManager';
let
testMissionId
=
2
;
try
{
missionManager
.
getMissionSnapShot
(
""
,
testMissionId
,
(
err
,
data
)
=>
{
missionManager
.
getMissionSnapShot
(
''
,
testMissionId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
getMissionSnapShot failed:
'
+
err
.
message
);
}
else
{
...
...
@@ -516,7 +516,7 @@ import missionManager from '@ohos.app.ability.missionManager';
let
testMissionId
=
2
;
try
{
missionManager
.
getMissionSnapShot
(
""
,
testMissionId
).
then
((
data
)
=>
{
missionManager
.
getMissionSnapShot
(
''
,
testMissionId
).
then
((
data
)
=>
{
console
.
info
(
'
getMissionSnapShot successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
getMissionSnapShot failed. Cause:
'
+
error
.
message
);
...
...
@@ -552,7 +552,7 @@ import missionManager from '@ohos.app.ability.missionManager';
let
testMissionId
=
2
;
try
{
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
testMissionId
,
(
err
,
data
)
=>
{
missionManager
.
getLowResolutionMissionSnapShot
(
''
,
testMissionId
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
getLowResolutionMissionSnapShot failed:
'
+
err
.
message
);
}
else
{
...
...
@@ -596,7 +596,7 @@ import missionManager from '@ohos.app.ability.missionManager';
let
testMissionId
=
2
;
try
{
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
testMissionId
).
then
((
data
)
=>
{
missionManager
.
getLowResolutionMissionSnapShot
(
''
,
testMissionId
).
then
((
data
)
=>
{
console
.
info
(
'
getLowResolutionMissionSnapShot successfully. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
error
(
'
getLowResolutionMissionSnapShot failed. Cause:
'
+
error
.
message
);
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md
浏览文件 @
e53420cc
...
...
@@ -68,16 +68,16 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<v
```
ts
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
);
}
```
...
...
@@ -108,15 +108,15 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>;
**示例:**
```
ts
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
);
}
```
...
...
@@ -143,16 +143,16 @@ getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<Applicat
```
ts
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
);
}
```
...
...
@@ -184,13 +184,13 @@ getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo
```
ts
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
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -202,11 +202,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
;
}
}
...
...
@@ -259,7 +259,7 @@ onDump(params: Array\<string>): Array\<string>;
class
MyUIAbility
extends
UIAbility
{
onDump
(
params
)
{
console
.
log
(
'
dump, params:
'
+
JSON
.
stringify
(
params
));
return
[
"
params
"
]
return
[
'
params
'
];
}
}
```
...
...
@@ -289,12 +289,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
;
}
}
...
...
@@ -339,8 +339,8 @@ call(method: string, data: rpc.Sequenceable): Promise<void>;
```
ts
class
MyMessageAble
{
// 自定义的Sequenceable数据结构
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -364,12 +364,12 @@ call(method: string, data: rpc.Sequenceable): Promise<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
;
let
msg
=
new
MyMessageAble
(
"
msg
"
,
"
world
"
);
// 参考Sequenceable数据定义
let
msg
=
new
MyMessageAble
(
'
msg
'
,
'
world
'
);
// 参考Sequenceable数据定义
caller
.
call
(
method
,
msg
)
.
then
(()
=>
{
console
.
log
(
'
Caller call() called
'
);
...
...
@@ -420,8 +420,8 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
```
ts
class
MyMessageAble
{
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -445,16 +445,16 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
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
;
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
)
=>
{
...
...
@@ -494,9 +494,9 @@ 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
{
...
...
@@ -534,9 +534,9 @@ 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
{
...
...
@@ -557,7 +557,7 @@ release(): void;
## Caller.on
on(type:
"release"
, callback: OnReleaseCallback): void;
on(type:
'release'
, callback: OnReleaseCallback): void;
注册通用组件服务端Stub(桩)断开监听通知。
...
...
@@ -585,13 +585,13 @@ 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
{
caller
.
on
(
"
release
"
,
(
str
)
=>
{
caller
.
on
(
'
release
'
,
(
str
)
=>
{
console
.
log
(
'
Caller OnRelease CallBack is called
'
+
str
);
});
}
catch
(
error
)
{
...
...
@@ -608,7 +608,7 @@ release(): void;
## Caller.off
off(type:
"release"
, callback: OnReleaseCallback): void;
off(type:
'release'
, callback: OnReleaseCallback): void;
取消注册通用组件服务端Stub(桩)断开监听通知。预留能力,当前暂未支持。
...
...
@@ -635,17 +635,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
));
...
...
@@ -660,7 +660,7 @@ off(type: "release", callback: OnReleaseCallback): void;
## Caller.off
off(type:
"release"
): void;
off(type:
'release'
): void;
取消注册通用组件服务端Stub(桩)断开监听通知。预留能力,当前暂未支持。
...
...
@@ -686,17 +686,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
));
...
...
@@ -740,8 +740,8 @@ on(method: string, callback: CalleeCallback): void;
```
ts
class
MyMessageAble
{
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -763,9 +763,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
MainUIAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-want.md
浏览文件 @
e53420cc
...
...
@@ -25,7 +25,7 @@ import Want from '@ohos.app.ability.Want';
|
[
action
](
js-apis-app-ability-wantConstant.md#wantConstant.Action
)
| string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。隐式Want定义及匹配规则请参见
[
显式Want与隐式Want匹配规则
](
application-models/explicit-implicit-want-mappings.md
)
。 |
|
[
entities
](
js-apis-app-ability-wantConstant.md#wantConstant.Entity
)
| Array
\<
string> | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器)。在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。 |
| uri | string | 否 | 表示携带的数据,一般配合type使用,指明待处理的数据类型。如果在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。 |
| 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文件才会有。 |
|
[
flags
](
js-apis-ability-wantConstant.md#wantconstantflags
)
| number | 否 | 表示处理Want的方式。默认传数字。
<br
/>
例如通过wantConstant.Flags.FLAG_ABILITY_CONTINUATION表示是否以设备间迁移方式启动Ability。 |
...
...
@@ -35,15 +35,15 @@ import Want from '@ohos.app.ability.Want';
```
ts
let
want
=
{
"
deviceId
"
:
""
,
// deviceId为空表示本设备
"
bundleName
"
:
"
com.example.myapplication
"
,
"
abilityName
"
:
"
FuncAbility
"
,
"
moduleName
"
:
"
entry
"
// moduleName非必选
'
deviceId
'
:
''
,
// deviceId为空表示本设备
'
bundleName
'
:
'
com.example.myapplication
'
,
'
abilityName
'
:
'
FuncAbility
'
,
'
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
);
})
;
```
-
通过自定字段传递数据, 以下为当前支持类型(在UIAbility对象中调用,其中示例中的context为UIAbility的上下文对象)。
...
...
@@ -51,84 +51,84 @@ import Want from '@ohos.app.ability.Want';
* 字符串(String)
```ts
let want = {
bundleName:
"com.example.myapplication"
,
abilityName:
"FuncAbility"
,
bundleName:
'com.example.myapplication'
,
abilityName:
'FuncAbility'
,
parameters: {
keyForString:
"str"
,
keyForString:
'str'
,
},
}
}
;
```
* 数字(Number)
```ts
let want = {
bundleName:
"com.example.myapplication"
,
abilityName:
"FuncAbility"
,
bundleName:
'com.example.myapplication'
,
abilityName:
'FuncAbility'
,
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
}
}
;
```
* 布尔(Boolean)
```ts
let want = {
bundleName:
"com.example.myapplication"
,
abilityName:
"FuncAbility"
,
bundleName:
'com.example.myapplication'
,
abilityName:
'FuncAbility'
,
parameters: {
keyForBool: true,
},
}
}
;
```
* 对象(Object)
```ts
let want = {
bundleName:
"com.example.myapplication"
,
abilityName:
"FuncAbility"
,
bundleName:
'com.example.myapplication'
,
abilityName:
'FuncAbility'
,
parameters: {
keyForObject: {
keyForObjectString:
"str"
,
keyForObjectString:
'str'
,
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
},
}
}
;
```
* 数组(Array)
```ts
let want = {
bundleName:
"com.example.myapplication"
,
abilityName:
"FuncAbility"
,
bundleName:
'com.example.myapplication'
,
abilityName:
'FuncAbility'
,
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';
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.example.myapplication"
,
"abilityName": "FuncAbility"
,
"moduleName": "entry"
, // moduleName非必选
"parameters"
: {
"keyFd":{"type":"FD", "value":fd} // {"type":"FD", "value"
:fd}是固定用法,用于表示该数据是FD
'deviceId': ''
, // deviceId为空表示本设备
'bundleName': 'com.example.myapplication'
,
'abilityName': 'FuncAbility'
,
'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)
})
;
```
-
更多详细说明和示例请参见:
[
应用模型
](
../../application-models/Readme-CN.md
)
的信息传递载体Want
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
浏览文件 @
e53420cc
...
...
@@ -85,7 +85,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -180,7 +180,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
...
...
@@ -268,7 +268,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -378,7 +378,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -480,7 +480,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -590,7 +590,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -692,7 +692,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -804,7 +804,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -905,7 +905,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -1015,7 +1015,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -1091,8 +1091,8 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\<Co
let
wantAgent
;
// triggerInfo
let
triggerInfo
=
{
code
:
0
//自定义义结果码
}
code
:
0
//自定义义结果码
};
//WantAgentInfo对象
let
wantAgentInfo
=
{
wants
:
[
...
...
@@ -1119,7 +1119,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -1226,7 +1226,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -1339,7 +1339,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -1439,7 +1439,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
@@ -1547,7 +1547,7 @@ let wantAgentInfo = {
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -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,10 +52,10 @@ import formBindingData from '@ohos.app.form.formBindingData';
import
fs
from
'
@ohos.file.fs
'
;
try
{
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
)
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
)
;
let
obj
=
{
"
temperature
"
:
"
21°
"
,
"
formImages
"
:
{
"
image
"
:
fd
}
'
temperature
'
:
'
21°
'
,
'
formImages
'
:
{
'
image
'
:
fd
}
};
formBindingData
.
createFormBindingData
(
obj
);
}
catch
(
error
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
浏览文件 @
e53420cc
...
...
@@ -51,8 +51,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
;
...
...
@@ -111,8 +111,8 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
onUpdateForm
(
formId
)
{
console
.
log
(
'
FormExtensionAbility onUpdateForm, formId:
'
+
formId
);
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
formProvider
.
updateForm
(
formId
,
obj2
).
then
((
data
)
=>
{
console
.
log
(
'
FormExtensionAbility context updateForm, data:
'
+
data
);
...
...
@@ -141,19 +141,19 @@ onChangeFormVisibility(newStatus: { [key: string]: number }): void
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onChangeFormVisibility
(
newStatus
)
{
console
.
log
(
'
FormExtensionAbility onChangeFormVisibility, newStatus:
'
+
newStatus
);
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
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
]);
formProvider
.
updateForm
(
key
,
obj2
).
then
((
data
)
=>
{
console
.
log
(
'
FormExtensionAbility context updateForm, data:
'
+
data
);
}).
catch
((
error
)
=>
{
...
...
@@ -186,7 +186,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
"
, message:
"
+
message
);
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
'
, message:
'
+
message
);
}
};
```
...
...
@@ -302,8 +302,8 @@ export default 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
浏览文件 @
e53420cc
...
...
@@ -43,7 +43,7 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -92,7 +92,7 @@ deleteForm(formId: string): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost deleteForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -133,7 +133,7 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -175,7 +175,7 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -222,7 +222,7 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost releaseForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -263,7 +263,7 @@ requestForm(formId: string, callback: AsyncCallback<void>): void
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -309,7 +309,7 @@ requestForm(formId: string): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost requestForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -351,7 +351,7 @@ castToNormalForm(formId: string, callback: AsyncCallback<void>): void
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
castToNormalForm
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -397,7 +397,7 @@ castToNormalForm(formId: string): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
castToNormalForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost castTempForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -438,7 +438,7 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -484,7 +484,7 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyVisibleForms success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -525,7 +525,7 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -571,7 +571,7 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyInvisibleForms success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -612,7 +612,7 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void&
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -658,7 +658,7 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost enableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -699,7 +699,7 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -745,7 +745,7 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost disableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -912,7 +912,7 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
else
{
...
...
@@ -955,7 +955,7 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
"
entry
"
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
else
{
...
...
@@ -1003,7 +1003,7 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI
import
formHost
from
'
@ohos.app.form.formHost
'
;
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
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -1036,7 +1036,7 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
...
...
@@ -1077,7 +1077,7 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>
import
formHost
from
'
@ohos.app.form.formHost
'
;
try
{
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
).
then
((
data
)
=>
{
console
.
log
(
'
formHost deleteInvalidForms, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -1118,13 +1118,13 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
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
{
...
...
@@ -1175,13 +1175,13 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
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
{
...
...
@@ -1195,9 +1195,9 @@ try {
}
```
## on(
"formUninstall"
)
## on(
'formUninstall'
)
on(type:
"formUninstall"
, callback: Callback
<
string
>
): void
on(type:
'formUninstall'
, callback: Callback
<
string
>
): void
订阅卡片卸载事件。使用callback异步回调。
...
...
@@ -1207,7 +1207,7 @@ on(type: "formUninstall", callback: Callback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| type | string | 是 | 填写
"formUninstall"
,表示卡片卸载事件。 |
| type | string | 是 | 填写
'formUninstall'
,表示卡片卸载事件。 |
| callback | Callback
<
string
>
| 是 | 回调函数。返回卡片标识。 |
**示例:**
...
...
@@ -1218,12 +1218,12 @@ import formHost from '@ohos.app.form.formHost';
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异步回调。
...
...
@@ -1233,8 +1233,8 @@ off(type: "formUninstall", callback?: Callback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| type | string | 是 | 填写
"formUninstall"
,表示卡片卸载事件。 |
| callback | Callback
<
string
>
| 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。
<br>
需与对应on(
"formUninstall"
)的callback一致。|
| type | string | 是 | 填写
'formUninstall'
,表示卡片卸载事件。 |
| callback | Callback
<
string
>
| 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。
<br>
需与对应on(
'formUninstall'
)的callback一致。|
**示例:**
...
...
@@ -1244,7 +1244,7 @@ import formHost from '@ohos.app.form.formHost';
let
callback
=
function
(
formId
)
{
console
.
log
(
'
formHost on formUninstall, formId:
'
+
formId
);
}
formHost
.
off
(
"
formUninstall
"
,
callback
);
formHost
.
off
(
'
formUninstall
'
,
callback
);
```
## notifyFormsVisible
...
...
@@ -1277,7 +1277,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsVisible
(
formIds
,
true
,
(
error
)
=>
{
if
(
error
)
{
...
...
@@ -1324,7 +1324,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsVisible
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsVisible success
'
);
...
...
@@ -1366,7 +1366,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
,
(
error
)
=>
{
if
(
error
)
{
...
...
@@ -1413,7 +1413,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean):
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsEnableUpdate success
'
);
...
...
@@ -1454,8 +1454,8 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>)
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
deviceId
=
"
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
"
;
let
formId
=
'
12400633174999288
'
;
let
deviceId
=
'
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
'
;
try
{
formHost
.
shareForm
(
formId
,
deviceId
,
(
error
)
=>
{
if
(
error
)
{
...
...
@@ -1502,8 +1502,8 @@ shareForm(formId: string, deviceId: string): Promise<void>
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
deviceId
=
"
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
"
;
let
formId
=
'
12400633174999288
'
;
let
deviceId
=
'
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
'
;
try
{
formHost
.
shareForm
(
formId
,
deviceId
).
then
(()
=>
{
console
.
log
(
'
formHost shareForm success
'
);
...
...
@@ -1545,7 +1545,7 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsPrivacyProtected
(
formIds
,
true
,
(
error
)
=>
{
if
(
error
)
{
...
...
@@ -1590,7 +1590,7 @@ function notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: bool
```
ts
import
formHost
from
'
@ohos.app.form.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
try
{
formHost
.
notifyFormsPrivacyProtected
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsPrivacyProtected success
'
);
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formInfo.md
浏览文件 @
e53420cc
...
...
@@ -92,16 +92,16 @@ import formInfo from '@ohos.app.form.formInfo';
| 名称 | 值 | 说明 |
| ----------- | ---- | ------------ |
| IDENTITY_KEY |
"ohos.extra.param.key.form_identity"
| 卡片标识。 |
| DIMENSION_KEY |
"ohos.extra.param.key.form_dimension"
| 卡片规格样式。 |
| NAME_KEY |
"ohos.extra.param.key.form_name"
| 卡片名称。 |
| MODULE_NAME_KEY |
"ohos.extra.param.key.module_name"
| 卡片所属模块名称。 |
| WIDTH_KEY |
"ohos.extra.param.key.form_width"
| 卡片宽度。 |
| HEIGHT_KEY |
"ohos.extra.param.key.form_height"
| 卡片高度。 |
| TEMPORARY_KEY |
"ohos.extra.param.key.form_temporary"
| 临时卡片。 |
| ABILITY_NAME_KEY |
"ohos.extra.param.key.ability_name"
| ability名称。 |
| DEVICE_ID_KEY |
"ohos.extra.param.key.device_id"
| 设备标识。 |
| BUNDLE_NAME_KEY |
"ohos.extra.param.key.bundle_name"
| 指示指定要获取的捆绑Bundle名称的键。 |
| IDENTITY_KEY |
'ohos.extra.param.key.form_identity'
| 卡片标识。 |
| DIMENSION_KEY |
'ohos.extra.param.key.form_dimension'
| 卡片规格样式。 |
| NAME_KEY |
'ohos.extra.param.key.form_name'
| 卡片名称。 |
| MODULE_NAME_KEY |
'ohos.extra.param.key.module_name'
| 卡片所属模块名称。 |
| WIDTH_KEY |
'ohos.extra.param.key.form_width'
| 卡片宽度。 |
| HEIGHT_KEY |
'ohos.extra.param.key.form_height'
| 卡片高度。 |
| TEMPORARY_KEY |
'ohos.extra.param.key.form_temporary'
| 临时卡片。 |
| ABILITY_NAME_KEY |
'ohos.extra.param.key.ability_name'
| ability名称。 |
| DEVICE_ID_KEY |
'ohos.extra.param.key.device_id'
| 设备标识。 |
| BUNDLE_NAME_KEY |
'ohos.extra.param.key.bundle_name'
| 指示指定要获取的捆绑Bundle名称的键。 |
## FormDimension
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md
浏览文件 @
e53420cc
...
...
@@ -39,7 +39,7 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
```
ts
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
try
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
,
(
error
,
data
)
=>
{
if
(
error
)
{
...
...
@@ -86,7 +86,7 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void>
```
ts
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
try
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
).
then
(()
=>
{
console
.
log
(
`formProvider setFormNextRefreshTime success`
);
...
...
@@ -127,9 +127,9 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
let
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
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
...
...
@@ -176,8 +176,8 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
let
formId
=
'
12400633174999288
'
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
try
{
formProvider
.
updateForm
(
formId
,
obj
).
then
(()
=>
{
console
.
log
(
`formProvider updateForm success`
);
...
...
@@ -258,7 +258,7 @@ import formProvider from '@ohos.app.form.formProvider';
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
"
entry
"
moduleName
:
'
entry
'
};
try
{
formProvider
.
getFormsInfo
(
filter
,
(
error
,
data
)
=>
{
...
...
@@ -308,7 +308,7 @@ import formProvider from '@ohos.app.form.formProvider';
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
"
entry
"
moduleName
:
'
entry
'
};
try
{
formProvider
.
getFormsInfo
(
filter
).
then
((
data
)
=>
{
...
...
@@ -335,7 +335,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
>
| 是 | 回调函数。返回卡片标识。 |
...
...
@@ -353,15 +353,15 @@ import formBindingData from '@ohos.app.form.formBindingData';
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
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
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
...
...
@@ -388,7 +388,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
>
| 是 | 回调函数。返回卡片标识。 |
**错误码:**
...
...
@@ -404,11 +404,11 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
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
{
...
...
@@ -438,7 +438,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
)
| 否 | 创建卡片的数据。 |
**返回值:**
...
...
@@ -460,11 +460,11 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
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
{
...
...
@@ -506,11 +506,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
{
...
...
@@ -557,11 +557,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
浏览文件 @
e53420cc
...
...
@@ -207,12 +207,12 @@ onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
**示例:**
```
ts
import
AbilityConstant
from
"
@ohos.app.ability.AbilityConstant
"
;
import
AbilityConstant
from
'
@ohos.app.ability.AbilityConstant
'
;
export
default
class
EntryAbility
extends
UIAbility
{
onContinue
(
wantParams
)
{
console
.
log
(
'
onContinue
'
);
wantParams
[
"
myData
"
]
=
"
my1234567
"
;
wantParams
[
'
myData
'
]
=
'
my1234567
'
;
return
AbilityConstant
.
OnContinueResult
.
AGREE
;
}
}
...
...
@@ -289,7 +289,7 @@ dump(params: Array\<string>): Array\<string>;
export
default
class
EntryAbility
extends
UIAbility
{
dump
(
params
)
{
console
.
log
(
'
dump, params:
'
+
JSON
.
stringify
(
params
));
return
[
"
params
"
]
return
[
'
params
'
];
}
}
```
...
...
@@ -347,7 +347,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
export
default
class
EntryAbility
extends
UIAbility
{
onSaveState
(
reason
,
wantParam
)
{
console
.
log
(
'
onSaveState
'
);
wantParam
[
"
myData
"
]
=
"
my1234567
"
;
wantParam
[
'
myData
'
]
=
'
my1234567
'
;
return
AbilityConstant
.
OnSaveResult
.
RECOVERY_AGREE
;
}
}
...
...
@@ -394,8 +394,8 @@ call(method: string, data: rpc.Sequenceable): Promise<void>;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
MyMessageAble
{
// 自定义的Sequenceable数据结构
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -419,12 +419,12 @@ call(method: string, data: rpc.Sequenceable): Promise<void>;
export
default
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
EntryAbility
'
,
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
'
);
...
...
@@ -479,8 +479,8 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
MyMessageAble
{
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -504,16 +504,16 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
export
default
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
EntryAbility
'
,
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
)
=>
{
...
...
@@ -556,9 +556,9 @@ release(): void;
export
default
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
EntryAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
...
...
@@ -599,9 +599,9 @@ release(): void;
export
default
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
abilityName
:
'
EntryAbility
'
,
deviceId
:
''
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
...
...
@@ -653,8 +653,8 @@ on(method: string, callback: CalleeCallBack): void;
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
MyMessageAble
{
name
:
""
str
:
""
name
:
''
str
:
''
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
...
...
@@ -676,9 +676,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
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
# @ohos.application.AbilityLifecycleCallback (AbilityLifecycleCallback)
AbilityLifecycleCallback模块提供应用上下文ApplicationContext的生命周期监听方法的回调类的能力,包括onAbilityCreate、onWindowStageCreate、onWindowStageDestroy等方法,可以作为
[
on(type:
"abilityLifecycle"
, callback: AbilityLifecycleCallback)
](
js-apis-inner-application-applicationContext.md#applicationcontextontype-abilitylifecycle-callback-abilitylifecyclecallback
)
的入参。
AbilityLifecycleCallback模块提供应用上下文ApplicationContext的生命周期监听方法的回调类的能力,包括onAbilityCreate、onWindowStageCreate、onWindowStageDestroy等方法,可以作为
[
on(type:
'abilityLifecycle'
, callback: AbilityLifecycleCallback)
](
js-apis-inner-application-applicationContext.md#applicationcontextontype-abilitylifecycle-callback-abilitylifecyclecallback
)
的入参。
> **说明:**
>
...
...
@@ -11,7 +11,7 @@ AbilityLifecycleCallback模块提供应用上下文ApplicationContext的生命
## 导入模块
```
ts
import
AbilityLifecycleCallback
from
"
@ohos.application.AbilityLifecycleCallback
"
;
import
AbilityLifecycleCallback
from
'
@ohos.application.AbilityLifecycleCallback
'
;
```
...
...
@@ -156,57 +156,57 @@ onAbilityContinue(ability: Ability): void;
**示例:**
```
ts
import
AbilityStage
from
"
@ohos.app.ability.AbilityStage
"
;
import
AbilityStage
from
'
@ohos.app.ability.AbilityStage
'
;
let
lifecycleId
;
export
default
class
MyAbilityStage
extends
AbilityStage
{
onCreate
()
{
console
.
log
(
"
MyAbilityStage onCreate
"
)
console
.
log
(
'
MyAbilityStage onCreate
'
)
let
AbilityLifecycleCallback
=
{
onAbilityCreate
(
ability
)
{
console
.
log
(
"
onAbilityCreate ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
onAbilityCreate ability:
'
+
JSON
.
stringify
(
ability
));
},
onWindowStageCreate
(
ability
,
windowStage
)
{
console
.
log
(
"
onWindowStageCreate ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
"
onWindowStageCreate windowStage:
"
+
JSON
.
stringify
(
windowStage
));
console
.
log
(
'
onWindowStageCreate ability:
'
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
onWindowStageCreate windowStage:
'
+
JSON
.
stringify
(
windowStage
));
},
onWindowStageActive
(
ability
,
windowStage
)
{
console
.
log
(
"
onWindowStageActive ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
"
onWindowStageActive windowStage:
"
+
JSON
.
stringify
(
windowStage
));
console
.
log
(
'
onWindowStageActive ability:
'
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
onWindowStageActive windowStage:
'
+
JSON
.
stringify
(
windowStage
));
},
onWindowStageInactive
(
ability
,
windowStage
)
{
console
.
log
(
"
onWindowStageInactive ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
"
onWindowStageInactive windowStage:
"
+
JSON
.
stringify
(
windowStage
));
console
.
log
(
'
onWindowStageInactive ability:
'
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
onWindowStageInactive windowStage:
'
+
JSON
.
stringify
(
windowStage
));
},
onWindowStageDestroy
(
ability
,
windowStage
)
{
console
.
log
(
"
onWindowStageDestroy ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
"
onWindowStageDestroy windowStage:
"
+
JSON
.
stringify
(
windowStage
));
console
.
log
(
'
onWindowStageDestroy ability:
'
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
onWindowStageDestroy windowStage:
'
+
JSON
.
stringify
(
windowStage
));
},
onAbilityDestroy
(
ability
)
{
console
.
log
(
"
onAbilityDestroy ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
onAbilityDestroy ability:
'
+
JSON
.
stringify
(
ability
));
},
onAbilityForeground
(
ability
)
{
console
.
log
(
"
onAbilityForeground ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
onAbilityForeground ability:
'
+
JSON
.
stringify
(
ability
));
},
onAbilityBackground
(
ability
)
{
console
.
log
(
"
onAbilityBackground ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
onAbilityBackground ability:
'
+
JSON
.
stringify
(
ability
));
},
onAbilityContinue
(
ability
)
{
console
.
log
(
"
onAbilityContinue ability:
"
+
JSON
.
stringify
(
ability
));
console
.
log
(
'
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
浏览文件 @
e53420cc
...
...
@@ -51,11 +51,11 @@ updateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void
```
ts
let
config
=
{
language
:
'
chinese
'
}
}
;
abilityManager
.
updateConfiguration
(
config
,
()
=>
{
console
.
log
(
'
------------ updateConfiguration -----------
'
);
})
})
;
```
## updateConfiguration
...
...
@@ -85,13 +85,13 @@ updateConfiguration(config: Configuration): Promise\<void>
```
ts
let
config
=
{
language
:
'
chinese
'
}
}
;
abilityManager
.
updateConfiguration
(
config
).
then
(()
=>
{
console
.
log
(
'
updateConfiguration success
'
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
updateConfiguration fail
'
);
})
})
;
```
## getAbilityRunningInfos
...
...
@@ -114,7 +114,7 @@ getAbilityRunningInfos(callback: AsyncCallback\<Array\<AbilityRunningInfo>>): vo
```
ts
abilityManager
.
getAbilityRunningInfos
((
err
,
data
)
=>
{
console
.
log
(
"
getAbilityRunningInfos err:
"
+
err
+
"
data:
"
+
JSON
.
stringify
(
data
));
console
.
log
(
'
getAbilityRunningInfos err:
'
+
err
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -138,8 +138,8 @@ getAbilityRunningInfos(): Promise\<Array\<AbilityRunningInfo>>
```
ts
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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -152,7 +152,7 @@ getAppMemorySize(callback: AsyncCallback\<number>): void;
appManager
.
getAppMemorySize
((
err
,
data
)
=>
{
console
.
log
(
'
error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
The size of app memory is:
'
+
JSON
.
stringify
(
data
));
})
})
;
```
## appManager.getProcessRunningInfos<sup>(deprecated)</sup>
...
...
@@ -206,7 +206,7 @@ getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): vo
appManager
.
getProcessRunningInfos
((
err
,
data
)
=>
{
console
.
log
(
'
error:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
The process running infos is:
'
+
JSON
.
stringify
(
data
));
})
})
;
```
## appManager.registerApplicationStateObserver<sup>8+</sup>
...
...
@@ -230,7 +230,7 @@ registerApplicationStateObserver(observer: ApplicationStateObserver): number;
**示例:**
```
ts
var
applicationStateObserver
=
{
let
applicationStateObserver
=
{
onForegroundApplicationChanged
(
appStateData
)
{
console
.
log
(
'
------------ onForegroundApplicationChanged -----------
'
,
appStateData
);
},
...
...
@@ -246,7 +246,7 @@ registerApplicationStateObserver(observer: ApplicationStateObserver): number;
onProcessStateChanged
(
processData
)
{
console
.
log
(
'
------------ onProcessStateChanged -----------
'
,
processData
);
}
}
}
;
const
observerCode
=
appManager
.
registerApplicationStateObserver
(
applicationStateObserver
);
console
.
log
(
'
-------- observerCode: ---------
'
,
observerCode
);
```
...
...
@@ -273,7 +273,7 @@ registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameL
**示例:**
```
ts
var
applicationStateObserver
=
{
let
applicationStateObserver
=
{
onForegroundApplicationChanged
(
appStateData
)
{
console
.
log
(
'
------------ onForegroundApplicationChanged -----------
'
,
appStateData
);
},
...
...
@@ -289,8 +289,8 @@ registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameL
onProcessStateChanged
(
processData
)
{
console
.
log
(
'
------------ onProcessStateChanged -----------
'
,
processData
);
}
}
var
bundleNameList
=
[
'
bundleName1
'
,
'
bundleName2
'
];
}
;
let
bundleNameList
=
[
'
bundleName1
'
,
'
bundleName2
'
];
const
observerCode
=
appManager
.
registerApplicationStateObserver
(
applicationStateObserver
,
bundleNameList
);
console
.
log
(
'
-------- observerCode: ---------
'
,
observerCode
);
```
...
...
@@ -361,7 +361,7 @@ unregisterApplicationStateObserver(observerId: number): Promise\<void>;
})
.
catch
((
err
)
=>
{
console
.
log
(
'
----------- unregisterApplicationStateObserver fail ----------
'
,
err
);
})
})
;
```
## appManager.getForegroundApplications<sup>8+</sup>
...
...
@@ -389,7 +389,7 @@ getForegroundApplications(callback: AsyncCallback\<Array\<AppStateData>>): void;
if
(
err
)
{
console
.
log
(
'
--------- getForegroundApplicationsCallback fail ---------
'
,
err
);
}
else
{
console
.
log
(
'
--------- getForegroundApplicationsCallback success ---------
'
,
data
)
console
.
log
(
'
--------- getForegroundApplicationsCallback success ---------
'
,
data
)
;
}
}
appManager
.
getForegroundApplications
(
getForegroundApplicationsCallback
);
...
...
@@ -422,7 +422,7 @@ getForegroundApplications(): Promise\<Array\<AppStateData>>;
})
.
catch
((
err
)
=>
{
console
.
log
(
'
--------- getForegroundApplications fail -------
'
,
err
);
})
})
;
```
## appManager.killProcessWithAccount<sup>8+</sup>
...
...
@@ -455,7 +455,7 @@ appManager.killProcessWithAccount(bundleName, accountId)
})
.
catch
((
err
)
=>
{
console
.
log
(
'
------------ killProcessWithAccount fail ------------
'
,
err
);
})
})
;
```
...
...
@@ -561,7 +561,7 @@ killProcessesByBundleName(bundleName: string): Promise\<void>;
})
.
catch
((
err
)
=>
{
console
.
log
(
'
------------ killProcessesByBundleName fail ------------
'
,
err
);
})
})
;
```
## appManager.clearUpApplicationData<sup>8+</sup>
...
...
@@ -631,5 +631,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
浏览文件 @
e53420cc
...
...
@@ -31,7 +31,7 @@ export default class EntryAbility extends UIAbility {
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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -11,7 +11,7 @@ EnvironmentCallback模块提供应用上下文ApplicationContext对系统环境
## 导入模块
```
ts
import
EnvironmentCallback
from
"
@ohos.application.EnvironmentCallback
"
;
import
EnvironmentCallback
from
'
@ohos.application.EnvironmentCallback
'
;
```
...
...
@@ -52,26 +52,26 @@ 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
.
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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -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,10 +52,10 @@ import formBindingData from '@ohos.application.formBindingData';
import
fs
from
'
@ohos.file.fs
'
;
try
{
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
)
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
)
;
let
obj
=
{
"
temperature
"
:
"
21°
"
,
"
formImages
"
:
{
"
image
"
:
fd
}
'
temperature
'
:
'
21°
'
,
'
formImages
'
:
{
'
image
'
:
fd
}
};
formBindingData
.
createFormBindingData
(
obj
);
}
catch
(
error
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-application-formHost.md
浏览文件 @
e53420cc
...
...
@@ -36,7 +36,7 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost deleteForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -71,7 +71,7 @@ deleteForm(formId: string): Promise<void>
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
deleteForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost deleteForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -101,7 +101,7 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost releaseForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -134,7 +134,7 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost releaseForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -172,7 +172,7 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
releaseForm
(
formId
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost releaseForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -202,7 +202,7 @@ requestForm(formId: string, callback: AsyncCallback<void>): void
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost requestForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -237,7 +237,7 @@ requestForm(formId: string): Promise<void>
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
requestForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost requestForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -267,7 +267,7 @@ castTempForm(formId: string, callback: AsyncCallback<void>): void
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
castTempForm
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost castTempForm, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -302,7 +302,7 @@ castTempForm(formId: string): Promise<void>
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
castTempForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost castTempForm success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -332,7 +332,7 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost notifyVisibleForms, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -367,7 +367,7 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyVisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyVisibleForms success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -397,7 +397,7 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost notifyInvisibleForms, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -432,7 +432,7 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
notifyInvisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyInvisibleForms success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -462,7 +462,7 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void&
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost enableFormsUpdate, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -497,7 +497,7 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
enableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost enableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -527,7 +527,7 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost disableFormsUpdate, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -562,7 +562,7 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
'
12400633174999288
'
];
formHost
.
disableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost disableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -589,7 +589,7 @@ isSystemReady(callback: AsyncCallback<void>): void
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
isSystemReady
((
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost isSystemReady, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -616,7 +616,7 @@ isSystemReady(): Promise<void>
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formHost
.
isSystemReady
().
then
(()
=>
{
console
.
log
(
'
formHost isSystemReady success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -704,7 +704,7 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
...
...
@@ -736,7 +736,7 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
"
entry
"
,
(
error
,
data
)
=>
{
formHost
.
getFormsInfo
(
'
com.example.ohos.formjsdemo
'
,
'
entry
'
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
...
...
@@ -773,7 +773,7 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
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
.
error
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -802,7 +802,7 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost deleteInvalidForms, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -839,7 +839,7 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
deleteInvalidForms
(
formIds
).
then
((
data
)
=>
{
console
.
log
(
'
formHost deleteInvalidForms, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
...
...
@@ -870,13 +870,13 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g
import
formHost
from
'
@ohos.application.formHost
'
;
let
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
)
=>
{
...
...
@@ -916,13 +916,13 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
import
formHost
from
'
@ohos.application.formHost
'
;
let
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
)
=>
{
...
...
@@ -932,9 +932,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异步回调。
...
...
@@ -944,7 +944,7 @@ on(type: "formUninstall", callback: Callback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| type | string | 是 | 填写
"formUninstall"
,表示卡片卸载事件。 |
| type | string | 是 | 填写
'formUninstall'
,表示卡片卸载事件。 |
| callback | Callback
<
string
>
| 是 | 回调函数。返回卡片标识。 |
**示例:**
...
...
@@ -954,13 +954,13 @@ import formHost from '@ohos.application.formHost';
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异步回调。
...
...
@@ -970,8 +970,8 @@ off(type: "formUninstall", callback?: Callback<string>): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| type | string | 是 | 填写
"formUninstall"
,表示卡片卸载事件。 |
| callback | Callback
<
string
>
| 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。
<br>
需与对应on(
"formUninstall"
)的callback一致。|
| type | string | 是 | 填写
'formUninstall'
,表示卡片卸载事件。 |
| callback | Callback
<
string
>
| 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。
<br>
需与对应on(
'formUninstall'
)的callback一致。|
**示例:**
...
...
@@ -980,8 +980,8 @@ import formHost from '@ohos.application.formHost';
let
callback
=
function
(
formId
)
{
console
.
log
(
'
formHost on formUninstall, formId:
'
+
formId
);
}
formHost
.
off
(
"
formUninstall
"
,
callback
);
}
;
formHost
.
off
(
'
formUninstall
'
,
callback
);
```
## notifyFormsVisible
...
...
@@ -1007,7 +1007,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsVisible
(
formIds
,
true
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost notifyFormsVisible, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -1043,7 +1043,7 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsVisible
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsVisible success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -1074,7 +1074,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
error
(
'
formHost notifyFormsEnableUpdate, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -1110,7 +1110,7 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean):
```
ts
import
formHost
from
'
@ohos.application.formHost
'
;
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
'
12400633174999288
'
,
'
12400633174999289
'
);
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsEnableUpdate success
'
);
}).
catch
((
error
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-application-formInfo.md
浏览文件 @
e53420cc
...
...
@@ -93,11 +93,11 @@ import formInfo from '@ohos.application.formInfo';
| 名称 | 值 | 说明 |
| ----------- | ---- | ------------ |
| IDENTITY_KEY |
"ohos.extra.param.key.form_identity"
| 卡片标识。
<br>
**系统接口**
: 此接口为系统接口。 |
| DIMENSION_KEY |
"ohos.extra.param.key.form_dimension"
| 卡片规格样式。 |
| NAME_KEY |
"ohos.extra.param.key.form_name"
| 卡片名称。 |
| MODULE_NAME_KEY |
"ohos.extra.param.key.module_name"
| 卡片所属模块名称。 |
| WIDTH_KEY |
"ohos.extra.param.key.form_width"
| 卡片宽度。 |
| HEIGHT_KEY |
"ohos.extra.param.key.form_height"
| 卡片高度。 |
| TEMPORARY_KEY |
"ohos.extra.param.key.form_temporary"
| 临时卡片。 |
| IDENTITY_KEY |
'ohos.extra.param.key.form_identity'
| 卡片标识。
<br>
**系统接口**
: 此接口为系统接口。 |
| DIMENSION_KEY |
'ohos.extra.param.key.form_dimension'
| 卡片规格样式。 |
| NAME_KEY |
'ohos.extra.param.key.form_name'
| 卡片名称。 |
| MODULE_NAME_KEY |
'ohos.extra.param.key.module_name'
| 卡片所属模块名称。 |
| WIDTH_KEY |
'ohos.extra.param.key.form_width'
| 卡片宽度。 |
| HEIGHT_KEY |
'ohos.extra.param.key.form_height'
| 卡片高度。 |
| TEMPORARY_KEY |
'ohos.extra.param.key.form_temporary'
| 临时卡片。 |
zh-cn/application-dev/reference/apis/js-apis-application-formProvider.md
浏览文件 @
e53420cc
...
...
@@ -33,7 +33,7 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
```
ts
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formProvider
.
setFormNextRefreshTime
(
formId
,
5
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
'
formProvider setFormNextRefreshTime, error:
'
+
JSON
.
stringify
(
error
));
...
...
@@ -67,7 +67,7 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void>
```
ts
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
let
formId
=
'
12400633174999288
'
;
formProvider
.
setFormNextRefreshTime
(
formId
,
5
).
then
(()
=>
{
console
.
log
(
'
formProvider setFormNextRefreshTime success
'
);
}).
catch
((
error
)
=>
{
...
...
@@ -97,8 +97,8 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
let
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
));
...
...
@@ -133,8 +133,8 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
let
formId
=
'
12400633174999288
'
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
'
22c
'
,
time
:
'
22:00
'
});
formProvider
.
updateForm
(
formId
,
obj
).
then
(()
=>
{
console
.
log
(
'
formProvider updateForm success
'
);
}).
catch
((
error
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md
浏览文件 @
e53420cc
...
...
@@ -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,19 +80,19 @@ 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
)
{
...
...
@@ -165,22 +165,22 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
**示例:**
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
import
missionManager
from
'
@ohos.application.missionManager
'
;
let
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
""
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
let
allMissions
=
missionManager
.
getMissionInfos
(
''
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
''
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
console
.
log
(
'
getMissionInfo failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
return
;
}
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
);
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
);
});
```
...
...
@@ -213,9 +213,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
);
});
```
...
...
@@ -244,17 +244,17 @@ 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
)
=>
{
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
));
})
;
```
...
...
@@ -286,9 +286,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
);
});
```
...
...
@@ -317,27 +317,27 @@ 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
)
=>
{
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
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
missionManager
.
getMissionSnapShot
(
''
,
id
,
(
error
,
snapshot
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getMissionSnapShot failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
console
.
log
(
'
getMissionSnapShot failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
console
.
log
(
'
bundleName =
'
+
snapshot
.
ability
.
bundleName
);
});
})
;
```
...
...
@@ -369,17 +369,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
);
});
```
...
...
@@ -407,27 +407,27 @@ 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
)
=>
{
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
;
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
missionManager
.
getLowResolutionMissionSnapShot
(
''
,
id
,
(
error
,
snapshot
)
=>
{
if
(
error
.
code
)
{
console
.
log
(
"
getLowResolutionMissionSnapShot failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
console
.
log
(
'
getLowResolutionMissionSnapShot failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
return
;
}
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
})
})
console
.
log
(
'
bundleName =
'
+
snapshot
.
ability
.
bundleName
);
});
})
;
```
...
...
@@ -459,17 +459,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
);
});
```
...
...
@@ -497,21 +497,21 @@ 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
)
=>
{
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
;
missionManager
.
lockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
lockMission is called
"
);
});
console
.
log
(
'
lockMission is called
'
);
});
});
```
...
...
@@ -543,13 +543,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
){
...
...
@@ -580,21 +580,21 @@ 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
)
=>
{
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
;
missionManager
.
unlockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
unlockMission is called
"
);
});
console
.
log
(
'
unlockMission is called
'
);
});
});
```
...
...
@@ -626,14 +626,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
){
...
...
@@ -667,21 +667,21 @@ 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
)
=>
{
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
;
missionManager
.
clearMission
(
id
).
then
(()
=>
{
console
.
log
(
"
clearMission is called
"
);
});
console
.
log
(
'
clearMission is called
'
);
});
});
```
...
...
@@ -713,14 +713,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
){
...
...
@@ -747,7 +747,7 @@ clearAllMissions(callback: AsyncCallback<void>): void;
import
missionManager
from
'
@ohos.application.missionManager
'
missionManager
.
clearAllMissions
().
then
(()
=>
{
console
.
log
(
"
clearAllMissions is called
"
);
console
.
log
(
'
clearAllMissions is called
'
);
});
```
...
...
@@ -773,7 +773,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
);
});
...
...
@@ -802,21 +802,21 @@ 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
)
=>
{
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
;
missionManager
.
moveMissionToFront
(
id
).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
});
console
.
log
(
'
moveMissionToFront is called
'
);
});
});
```
...
...
@@ -844,20 +844,20 @@ 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
)
=>
{
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
;
missionManager
.
moveMissionToFront
(
id
,{
windowMode
:
101
}).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
console
.
log
(
'
moveMissionToFront is called
'
);
});
});
```
...
...
@@ -891,14 +891,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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -22,7 +22,7 @@ import Want from '@ohos.application.Want';
| bundleName | string | 否 | 表示Bundle名称。 |
| 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来表示对数据要执行的操作。具体参考:
[
action说明
](
js-apis-app-ability-wantConstant.md#wantConstant.Action
)
。隐式Want定义及匹配规则参考:
[
显式Want与隐式Want匹配规则
](
application-models/explicit-implicit-want-mappings.md
)
。 |
| 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
let
want
=
{
"
deviceId
"
:
""
,
// deviceId为空表示本设备
"
bundleName
"
:
"
com.example.myapplication
"
,
"
abilityName
"
:
"
EntryAbility
"
,
"
moduleName
"
:
"
entry
"
// moduleName非必选
'
deviceId
'
:
''
,
// deviceId为空表示本设备
'
bundleName
'
:
'
com.example.myapplication
'
,
'
abilityName
'
:
'
EntryAbility
'
,
'
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
)
})
;
```
-
通过自定字段传递数据, 以下为当前支持类型。(在UIAbility对象中调用,其中示例中的context为UIAbility的上下文对象)
...
...
@@ -51,84 +51,84 @@ import Want from '@ohos.application.Want';
* 字符串(String)
```ts
let want = {
bundleName:
"com.example.myapplication"
,
abilityName:
"EntryAbility"
,
bundleName:
'com.example.myapplication'
,
abilityName:
'EntryAbility'
,
parameters: {
keyForString:
"str"
,
keyForString:
'str'
,
},
}
}
;
```
* 数字(Number)
```ts
let want = {
bundleName:
"com.example.myapplication"
,
abilityName:
"EntryAbility"
,
bundleName:
'com.example.myapplication'
,
abilityName:
'EntryAbility'
,
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
}
}
;
```
* 布尔(Boolean)
```ts
let want = {
bundleName:
"com.example.myapplication"
,
abilityName:
"EntryAbility"
,
bundleName:
'com.example.myapplication'
,
abilityName:
'EntryAbility'
,
parameters: {
keyForBool: true,
},
}
}
;
```
* 对象(Object)
```ts
let want = {
bundleName:
"com.example.myapplication"
,
abilityName:
"EntryAbility"
,
bundleName:
'com.example.myapplication'
,
abilityName:
'EntryAbility'
,
parameters: {
keyForObject: {
keyForObjectString:
"str"
,
keyForObjectString:
'str'
,
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
},
}
}
;
```
* 数组(Array)
```ts
let want = {
bundleName:
"com.example.myapplication"
,
abilityName:
"EntryAbility"
,
bundleName:
'com.example.myapplication'
,
abilityName:
'EntryAbility'
,
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';
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.example.myapplication"
,
"abilityName": "EntryAbility"
,
"moduleName": "entry"
, // moduleName非必选
"parameters"
: {
"keyFd":{"type":"FD", "value"
:fd}
'deviceId': ''
, // deviceId为空表示本设备
'bundleName': 'com.example.myapplication'
,
'abilityName': 'EntryAbility'
,
'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)
})
;
```
-
更多详细说明和示例请参见:
[
应用模型
](
../../application-models/Readme-CN.md
)
的信息传递载体Want
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -36,11 +36,11 @@ openFile(uri: string, mode: string, callback: AsyncCallback\<number>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
let
mode
=
"
rw
"
;
DAHelper
.
openFile
(
"
dataability:///com.example.DataAbility
"
,
mode
,
(
err
,
data
)
=>
{
console
.
info
(
"
openFile err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
let
mode
=
'
rw
'
;
DAHelper
.
openFile
(
'
dataability:///com.example.DataAbility
'
,
mode
,
(
err
,
data
)
=>
{
console
.
info
(
'
openFile err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -70,11 +70,11 @@ openFile(uri: string, mode: string): Promise\<number>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
let
mode
=
"
rw
"
;
DAHelper
.
openFile
(
"
dataability:///com.example.DataAbility
"
,
mode
).
then
((
data
)
=>
{
console
.
info
(
"
openFile data:
"
+
JSON
.
stringify
(
data
));
let
mode
=
'
rw
'
;
DAHelper
.
openFile
(
'
dataability:///com.example.DataAbility
'
,
mode
).
then
((
data
)
=>
{
console
.
info
(
'
openFile data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -90,7 +90,7 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback\<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------ |
| type | string | 是 | 指示监听操作类型,
"dataChange"
表示数据变化操作。 |
| type | string | 是 | 指示监听操作类型,
'dataChange'
表示数据变化操作。 |
| uri | string | 是 | 指示待监听数据变化的uri。 |
| callback | AsyncCallback
\<
void> | 是 | 指示数据变化时的回调方法。 |
...
...
@@ -99,14 +99,14 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback\<void>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
function
onChangeNotify
()
{
console
.
info
(
"
onChangeNotify call back
"
);
console
.
info
(
'
onChangeNotify call back
'
);
};
DAHelper
.
on
(
"
dataChange
"
,
"
dataability:///com.example.DataAbility
"
,
'
dataChange
'
,
'
dataability:///com.example.DataAbility
'
,
onChangeNotify
);
```
...
...
@@ -123,7 +123,7 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback\<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------ |
| type | string | 是 | 指示监听操作类型,
"dataChange"
表示数据变化操作。 |
| type | string | 是 | 指示监听操作类型,
'dataChange'
表示数据变化操作。 |
| uri | string | 是 | 指示待取消监听数据变化的uri。 |
| callback | AsyncCallback
\<
void> | 否 | 指示已注册的数据变化回调方法。如果设置数据变化回调为空,将会取消所有数据变化监听。 |
...
...
@@ -132,19 +132,19 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback\<void>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
function
onChangeNotify
()
{
console
.
info
(
"
onChangeNotify call back
"
);
console
.
info
(
'
onChangeNotify call back
'
);
};
DAHelper
.
off
(
"
dataChange
"
,
"
dataability:///com.example.DataAbility
"
,
'
dataChange
'
,
'
dataability:///com.example.DataAbility
'
,
onChangeNotify
);
DAHelper
.
off
(
"
dataChange
"
,
"
dataability:///com.example.DataAbility
"
,
'
dataChange
'
,
'
dataability:///com.example.DataAbility
'
,
);
```
...
...
@@ -168,10 +168,10 @@ getType(uri: string, callback: AsyncCallback\<string>): void
```
ts
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
(
"
getType err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
getType
(
'
dataability:///com.example.DataAbility
'
,
(
err
,
data
)
=>
{
console
.
info
(
'
getType err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -200,10 +200,10 @@ getType(uri: string): Promise\<string>
```
ts
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
(
"
getType data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
getType
(
'
dataability:///com.example.DataAbility
'
).
then
((
data
)
=>
{
console
.
info
(
'
getType data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -228,10 +228,10 @@ getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array\
```
ts
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
(
"
getFileTypes err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
getFileTypes
(
'
dataability:///com.example.DataAbility
'
,
'
image/*
'
,
(
err
,
data
)
=>
{
console
.
info
(
'
getFileTypes err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -261,10 +261,10 @@ getFileTypes(uri: string, mimeTypeFilter: string): Promise\<Array\<string>>
```
ts
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
(
"
getFileTypes data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
getFileTypes
(
'
dataability:///com.example.DataAbility
'
,
'
image/*
'
).
then
((
data
)
=>
{
console
.
info
(
'
getFileTypes data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -288,10 +288,10 @@ normalizeUri(uri: string, callback: AsyncCallback\<string>): void
```
ts
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
(
"
normalizeUri err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
normalizeUri
(
'
dataability:///com.example.DataAbility
'
,
(
err
,
data
)
=>
{
console
.
info
(
'
normalizeUri err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -320,10 +320,10 @@ normalizeUri(uri: string): Promise\<string>
```
ts
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
(
"
normalizeUri data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
normalizeUri
(
'
dataability:///com.example.DataAbility
'
,).
then
((
data
)
=>
{
console
.
info
(
'
normalizeUri data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -347,10 +347,10 @@ denormalizeUri(uri: string, callback: AsyncCallback\<string>): void
```
ts
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
(
"
denormalizeUri err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
denormalizeUri
(
'
dataability:///com.example.DataAbility
'
,
(
err
,
data
)
=>
{
console
.
info
(
'
denormalizeUri err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -379,10 +379,10 @@ denormalizeUri(uri: string): Promise\<string>
```
ts
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
(
"
denormalizeUri data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
denormalizeUri
(
'
dataability:///com.example.DataAbility
'
,).
then
((
data
)
=>
{
console
.
info
(
'
denormalizeUri data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -406,10 +406,10 @@ notifyChange(uri: string, callback: AsyncCallback\<void>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
'
dataability:///com.example.DataAbility
'
);
DAHelper
.
notifyChange
(
"
dataability:///com.example.DataAbility
"
,
(
err
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
DAHelper
.
notifyChange
(
'
dataability:///com.example.DataAbility
'
,
(
err
)
=>
{
console
.
info
(
'
==========================>Called=======================>
'
);
});
```
...
...
@@ -438,10 +438,10 @@ notifyChange(uri: string): Promise\<void>
```
ts
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================>
'
);
});
```
...
...
@@ -466,16 +466,16 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\<num
```
ts
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
"
,
'
name
'
:
'
rose
'
,
'
age
'
:
22
,
'
salary
'
:
200.5
,
'
blobType
'
:
'
u8
'
,
};
DAHelper
.
insert
(
"
dataability:///com.example.DataAbility
"
,
valueBucket
,
(
err
,
data
)
=>
{
console
.
info
(
"
insert err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
insert
(
'
dataability:///com.example.DataAbility
'
,
valueBucket
,
(
err
,
data
)
=>
{
console
.
info
(
'
insert err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -505,16 +505,16 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket): Promise\<number>
```
ts
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
"
,
'
name
'
:
'
rose1
'
,
'
age
'
:
221
,
'
salary
'
:
20.5
,
'
blobType
'
:
'
u8
'
,
};
DAHelper
.
insert
(
"
dataability:///com.example.DataAbility
"
,
valueBucket
).
then
((
data
)
=>
{
console
.
info
(
"
insert data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
insert
(
'
dataability:///com.example.DataAbility
'
,
valueBucket
).
then
((
data
)
=>
{
console
.
info
(
'
insert data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -539,13 +539,13 @@ batchInsert(uri: string, valuesBuckets: Array\<rdb.ValuesBucket>, callback: Asyn
```
ts
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
,
(
err
,
data
)
=>
{
console
.
info
(
"
batchInsert err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
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
(
'
batchInsert err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -575,13 +575,13 @@ batchInsert(uri: string, valuesBuckets: Array<rdb.ValuesBucket>): Promise\<numbe
```
ts
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
(
"
batchInsert data:
"
+
JSON
.
stringify
(
data
));
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
(
'
batchInsert data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -607,11 +607,11 @@ delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: Asy
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
,
(
err
,
data
)
=>
{
console
.
info
(
"
delete err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
delete
(
'
dataability:///com.example.DataAbility
'
,
da
,
(
err
,
data
)
=>
{
console
.
info
(
'
delete err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -642,11 +642,11 @@ delete(uri: string, predicates?: dataAbility.DataAbilityPredicates): Promise\<nu
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
(
"
delete data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
delete
(
'
dataability:///com.example.DataAbility
'
,
da
).
then
((
data
)
=>
{
console
.
info
(
'
delete data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -673,17 +673,17 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.Data
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
"
,
'
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
(
"
update err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
update
(
'
dataability:///com.example.DataAbility
'
,
va
,
da
,
(
err
,
data
)
=>
{
console
.
info
(
'
update err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -715,17 +715,17 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates?: dataAbility.Dat
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
"
,
'
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
(
"
update data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
update
(
'
dataability:///com.example.DataAbility
'
,
va
,
da
).
then
((
data
)
=>
{
console
.
info
(
'
update data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -752,12 +752,12 @@ query(uri: string, columns: Array\<string>, predicates: dataAbility.DataAbilityP
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
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
(
"
query err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
query
(
'
dataability:///com.example.DataAbility
'
,
cars
,
da
,
(
err
,
data
)
=>
{
console
.
info
(
'
query err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -791,12 +791,12 @@ query(uri: string, columns?: Array\<string>, predicates?: dataAbility.DataAbilit
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
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
(
"
query data:
"
+
JSON
.
stringify
(
data
));
DAHelper
.
query
(
'
dataability:///com.example.DataAbility
'
,
cars
,
da
).
then
((
data
)
=>
{
console
.
info
(
'
query data:
'
+
JSON
.
stringify
(
data
));
});
```
...
...
@@ -812,7 +812,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
)
| 是 | 指示扩展的键值对参数。 |
...
...
@@ -824,10 +824,10 @@ 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
"
'
dataability:///com.example.jsapidemo.UserDataAbility
'
);
dataAbilityHelper
.
call
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
,
"
method
"
,
"
arg
"
,
{
"
key1
"
:
"
value1
"
},
(
err
,
data
)
=>
{
dataAbilityHelper
.
call
(
'
dataability:///com.example.jsapidemo.UserDataAbility
'
,
'
method
'
,
'
arg
'
,
{
'
key1
'
:
'
value1
'
},
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
err
);
return
;
...
...
@@ -848,7 +848,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
)
| 是 | 指示扩展的键值对参数。 |
...
...
@@ -865,10 +865,10 @@ 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
"
'
dataability:///com.example.jsapidemo.UserDataAbility
'
);
dataAbilityHelper
.
call
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
,
"
method
"
,
"
arg
"
,
{
"
key1
"
:
"
value1
"
}).
then
((
data
)
=>
{
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
);
...
...
@@ -887,7 +887,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数组中返回每个操作的结果。 |
...
...
@@ -899,9 +899,9 @@ import featureAbility from '@ohos.ability.featureAbility';
// 根据DataAbilityOperation列表选择要对数据库做的操作
let
op
=
new
Array
();
let
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
'
dataability:///com.example.jsapidemo.UserDataAbility
'
);
dataAbilityHelper
.
executeBatch
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
,
op
,
(
err
,
data
)
=>
{
dataAbilityHelper
.
executeBatch
(
'
dataability:///com.example.jsapidemo.UserDataAbility
'
,
op
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
Operation failed. Cause:
'
+
err
);
return
;
...
...
@@ -922,7 +922,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
)
> | 是 | 指示数据操作数组,其中可以包含对数据库的多个不同操作。 |
**返回值:**
...
...
@@ -939,9 +939,9 @@ import featureAbility from '@ohos.ability.featureAbility';
// 根据DataAbilityOperation列表选择要对数据库做的操作
let
op
=
new
Array
();
let
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
'
dataability:///com.example.jsapidemo.UserDataAbility
'
);
dataAbilityHelper
.
executeBatch
(
"
dataability:///com.example.jsapidemo.UserDataAbility
"
,
op
).
then
((
data
)
=>
{
dataAbilityHelper
.
executeBatch
(
'
dataability:///com.example.jsapidemo.UserDataAbility
'
,
op
).
then
((
data
)
=>
{
console
.
info
(
'
Operation succeeded:
'
+
data
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation failed. Cause:
'
+
error
);
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityOperation.md
浏览文件 @
e53420cc
...
...
@@ -11,7 +11,7 @@
| 名称 | 类型 | 必填| 说明 |
| -------- | -------- | --------| -------- |
| uri | string | 是 | 指示待处理的DataAbility。例:
"dataability:///com.example.xxx.xxxx"
。 |
| uri | string | 是 | 指示待处理的DataAbility。例:
'dataability:///com.example.xxx.xxxx'
。 |
| type | featureAbility.DataAbilityOperationType | 是 | 指示数据操作类型。 |
| valuesBucket? | rdb.ValuesBucket | 否 | 指示要操作的数据值。 |
| valueBackReferences? | rdb.ValuesBucket | 否 | 指示包含一组键值对的valuesBucket对象。 |
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md
浏览文件 @
e53420cc
...
...
@@ -11,21 +11,21 @@
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| 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
'
;
// 批量执行数据库操作
function
executeBatchOperation
()
{
let
dataAbilityUri
=
(
"
dataability:///com.example.myapplication.TestDataAbility
"
);
let
dataAbilityUri
=
(
'
dataability:///com.example.myapplication.TestDataAbility
'
);
let
DAHelper
;
try
{
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
dataAbilityUri
);
if
(
DAHelper
==
null
)
{
if
(
DAHelper
==
=
null
)
{
console
.
error
(
'
DAHelper is null
'
);
return
;
}
...
...
@@ -35,9 +35,9 @@ function executeBatchOperation() {
}
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
浏览文件 @
e53420cc
...
...
@@ -16,24 +16,24 @@
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
Want
=
{
bundleName
:
"
com.example.abilityStartSettingApp2
"
,
abilityName
:
"
com.example.abilityStartSettingApp.EntryAbility
"
,
}
bundleName
:
'
com.example.abilityStartSettingApp2
'
,
abilityName
:
'
com.example.abilityStartSettingApp.EntryAbility
'
,
}
;
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
}
}
;
try
{
featureAbility
.
startAbility
(
startAbilityParameter
,
(
err
,
data
)
=>
{
...
...
@@ -41,6 +41,6 @@ try {
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
浏览文件 @
e53420cc
...
...
@@ -14,7 +14,7 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传
| bundleName | string | 否 | 表示Bundle名称。 |
| 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来表示对数据要执行的操作。具体参考:
[
action说明
](
js-apis-app-ability-wantConstant.md#wantConstant.Action
)
。隐式Want定义及匹配规则参考:
[
显式Want与隐式Want匹配规则
](
application-models/explicit-implicit-want-mappings.md
)
。 |
| 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,14 +27,14 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传
```
ts
let
want
=
{
"
deviceId
"
:
""
,
// deviceId为空表示本设备
"
bundleName
"
:
"
com.example.myapplication
"
,
"
abilityName
"
:
"
EntryAbility
"
,
"
moduleName
"
:
"
entry
"
// moduleName非必选
'
deviceId
'
:
''
,
// deviceId为空表示本设备
'
bundleName
'
:
'
com.example.myapplication
'
,
'
abilityName
'
:
'
EntryAbility
'
,
'
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
)
})
```
...
...
@@ -46,23 +46,23 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传
// ...
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.example.myapplication
"
,
"
abilityName
"
:
"
EntryAbility
"
,
"
moduleName
"
:
"
entry
"
,
// moduleName非必选
"
parameters
"
:
{
"
keyFd
"
:{
"
type
"
:
"
FD
"
,
"
value
"
:
fd
}
'
deviceId
'
:
''
,
// deviceId为空表示本设备
'
bundleName
'
:
'
com.example.myapplication
'
,
'
abilityName
'
:
'
EntryAbility
'
,
'
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
浏览文件 @
e53420cc
...
...
@@ -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.bundleManager
'
;
let
context
=
featureAbility
.
getContext
();
bundle
.
getBundleInfo
(
'
com.context.test
'
,
1
,
(
err
,
datainfo
)
=>
{
context
.
verifyPermission
(
"
com.example.permission
"
,
{
uid
:
datainfo
.
appInfo
.
uid
},
(
err
,
data
)
=>
{
console
.
info
(
"
verifyPermission err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
context
.
verifyPermission
(
'
com.example.permission
'
,
{
uid
:
datainfo
.
appInfo
.
uid
},
(
err
,
data
)
=>
{
console
.
info
(
'
verifyPermission err:
'
+
JSON
.
stringify
(
err
)
+
'
data:
'
+
JSON
.
stringify
(
data
));
});
});
```
...
...
@@ -125,8 +125,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
));
});
```
...
...
@@ -158,7 +158,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
));
});
```
...
...
@@ -186,14 +186,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
));
}
);
```
...
...
@@ -226,13 +226,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
));
}
);
```
...
...
@@ -259,7 +259,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
));
});
```
...
...
@@ -285,7 +285,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
));
});
```
...
...
@@ -311,7 +311,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
));
});
```
...
...
@@ -337,7 +337,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
));
});
```
...
...
@@ -361,7 +361,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
));
});
```
...
...
@@ -385,7 +385,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
));
});
```
...
...
@@ -409,7 +409,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
));
});
```
...
...
@@ -433,7 +433,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
));
});
```
...
...
@@ -460,7 +460,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
));
});
```
...
...
@@ -487,7 +487,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
));
});
```
...
...
@@ -513,7 +513,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
));
});
```
...
...
@@ -544,7 +544,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
));
});
```
...
...
@@ -570,7 +570,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
));
});
```
...
...
@@ -601,7 +601,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
));
});
```
...
...
@@ -628,7 +628,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
));
});
```
...
...
@@ -654,7 +654,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
));
});
```
...
...
@@ -682,7 +682,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
));
});
```
...
...
@@ -710,7 +710,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
));
});
```
...
...
@@ -734,7 +734,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
));
});
```
...
...
@@ -760,7 +760,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
));
});
```
...
...
@@ -786,7 +786,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
));
});
```
...
...
@@ -812,7 +812,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
));
});
```
...
...
@@ -836,7 +836,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
));
});
```
...
...
@@ -860,7 +860,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
));
});
```
...
...
@@ -884,7 +884,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
));
});
```
...
...
@@ -908,7 +908,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
));
});
```
...
...
@@ -934,7 +934,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
));
});
```
...
...
@@ -960,7 +960,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
));
});
```
...
...
@@ -984,7 +984,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
));
});
```
...
...
@@ -1008,7 +1008,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
));
});
```
...
...
@@ -1032,7 +1032,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
));
});
```
...
...
@@ -1056,7 +1056,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
));
});
```
...
...
@@ -1080,7 +1080,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
));
});
```
...
...
@@ -1104,7 +1104,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
));
});
```
...
...
@@ -1128,7 +1128,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
));
});
```
...
...
@@ -1152,7 +1152,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
));
});
```
...
...
@@ -1197,7 +1197,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
));
});
```
...
...
@@ -1221,7 +1221,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
));
});
```
...
...
@@ -1269,7 +1269,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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -38,17 +38,17 @@ addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): void
let
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
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>;
let
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
addAbilityMonitor
(
monitor
).
then
(()
=>
{
console
.
info
(
"
addAbilityMonitor promise
"
);
console
.
info
(
'
addAbilityMonitor promise
'
);
});
```
...
...
@@ -113,17 +113,17 @@ removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): v
let
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
removeAbilityMonitor
(
monitor
,
(
err
:
any
)
=>
{
console
.
info
(
"
removeAbilityMonitor callback
"
);
console
.
info
(
'
removeAbilityMonitor callback
'
);
});
```
...
...
@@ -153,17 +153,17 @@ removeAbilityMonitor(monitor: AbilityMonitor): Promise\<void>;
let
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
removeAbilityMonitor
(
monitor
).
then
(()
=>
{
console
.
info
(
"
removeAbilityMonitor promise
"
);
console
.
info
(
'
removeAbilityMonitor promise
'
);
});
```
...
...
@@ -188,17 +188,17 @@ waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<UIAbility>)
let
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
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
'
);
});
```
...
...
@@ -225,17 +225,17 @@ let abilityDelegator;
let
timeout
=
100
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
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
'
);
});
```
...
...
@@ -268,17 +268,17 @@ waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\<UIAbilit
let
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
monitor
=
{
abilityName
:
"
abilityname
"
,
abilityName
:
'
abilityname
'
,
onAbilityCreate
:
onAbilityCreateCallback
}
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
waitAbilityMonitor
(
monitor
).
then
((
data
:
any
)
=>
{
console
.
info
(
"
waitAbilityMonitor promise
"
);
console
.
info
(
'
waitAbilityMonitor promise
'
);
});
```
...
...
@@ -333,10 +333,10 @@ let ability;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
getCurrentTopAbility
((
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
getCurrentTopAbility callback
"
);
console
.
info
(
'
getCurrentTopAbility callback
'
);
ability
=
data
;
let
state
=
abilityDelegator
.
getAbilityState
(
ability
);
console
.
info
(
"
getAbilityState
"
+
state
);
console
.
info
(
'
getAbilityState
'
+
state
);
});
```
...
...
@@ -362,7 +362,7 @@ let ability;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
getCurrentTopAbility
((
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
getCurrentTopAbility callback
"
);
console
.
info
(
'
getCurrentTopAbility callback
'
);
ability
=
data
;
});
```
...
...
@@ -389,7 +389,7 @@ let ability;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
getCurrentTopAbility
().
then
((
data
:
any
)
=>
{
console
.
info
(
"
getCurrentTopAbility promise
"
);
console
.
info
(
'
getCurrentTopAbility promise
'
);
ability
=
data
;
});
```
...
...
@@ -414,13 +414,13 @@ startAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
abilityDelegator
;
let
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
'
);
});
```
...
...
@@ -449,13 +449,13 @@ startAbility(want: Want): Promise\<void>;
```
ts
let
abilityDelegator
;
let
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
'
);
});
```
...
...
@@ -482,10 +482,10 @@ let 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
'
);
});
});
```
...
...
@@ -518,10 +518,10 @@ let 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
'
);
});
});
```
...
...
@@ -549,10 +549,10 @@ let 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
'
);
});
});
```
...
...
@@ -585,10 +585,10 @@ let 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
'
);
});
});
```
...
...
@@ -611,7 +611,7 @@ printSync(msg: string): void;
```
ts
let
abilityDelegator
;
let
msg
=
"
msg
"
;
let
msg
=
'
msg
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
printSync
(
msg
);
...
...
@@ -636,11 +636,11 @@ print(msg: string, callback: AsyncCallback\<void>): void;
```
ts
let
abilityDelegator
;
let
msg
=
"
msg
"
;
let
msg
=
'
msg
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
print
(
msg
,
(
err
:
any
)
=>
{
console
.
info
(
"
print callback
"
);
console
.
info
(
'
print callback
'
);
});
```
...
...
@@ -668,11 +668,11 @@ print(msg: string): Promise\<void>;
```
ts
let
abilityDelegator
;
let
msg
=
"
msg
"
;
let
msg
=
'
msg
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
print
(
msg
).
then
(()
=>
{
console
.
info
(
"
print promise
"
);
console
.
info
(
'
print promise
'
);
});
```
...
...
@@ -695,11 +695,11 @@ executeShellCommand(cmd: string, callback: AsyncCallback\<ShellCmdResult>): void
```
ts
let
abilityDelegator
;
let
cmd
=
"
cmd
"
;
let
cmd
=
'
cmd
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
executeShellCommand callback
"
);
console
.
info
(
'
executeShellCommand callback
'
);
});
```
...
...
@@ -723,12 +723,12 @@ executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback\<S
```
ts
let
abilityDelegator
;
let
cmd
=
"
cmd
"
;
let
cmd
=
'
cmd
'
;
let
timeout
=
100
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
executeShellCommand
(
cmd
,
timeout
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
executeShellCommand callback
"
);
console
.
info
(
'
executeShellCommand callback
'
);
});
```
...
...
@@ -757,12 +757,12 @@ executeShellCommand(cmd: string, timeoutSecs?: number): Promise\<ShellCmdResult>
```
ts
let
abilityDelegator
;
let
cmd
=
"
cmd
"
;
let
cmd
=
'
cmd
'
;
let
timeout
=
100
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
executeShellCommand
(
cmd
,
timeout
).
then
((
data
:
any
)
=>
{
console
.
info
(
"
executeShellCommand promise
"
);
console
.
info
(
'
executeShellCommand promise
'
);
});
```
...
...
@@ -786,11 +786,11 @@ finishTest(msg: string, code: number, callback: AsyncCallback\<void>): void;
```
ts
let
abilityDelegator
;
let
msg
=
"
msg
"
;
let
msg
=
'
msg
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
finishTest
(
msg
,
0
,
(
err
:
any
)
=>
{
console
.
info
(
"
finishTest callback
"
);
console
.
info
(
'
finishTest callback
'
);
});
```
...
...
@@ -819,11 +819,11 @@ finishTest(msg: string, code: number): Promise\<void>;
```
ts
let
abilityDelegator
;
let
msg
=
"
msg
"
;
let
msg
=
'
msg
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
finishTest
(
msg
,
0
).
then
(()
=>
{
console
.
info
(
"
finishTest promise
"
);
console
.
info
(
'
finishTest promise
'
);
});
```
...
...
@@ -848,13 +848,13 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<vo
let
abilityDelegator
;
let
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
'
);
});
```
...
...
@@ -884,13 +884,13 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
let
abilityDelegator
;
let
monitor
=
{
moduleName
:
"
moduleName
"
,
srcEntrance
:
"
srcEntrance
"
,
}
moduleName
:
'
moduleName
'
,
srcEntrance
:
'
srcEntrance
'
,
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
addAbilityStageMonitor
(
monitor
).
then
(()
=>
{
console
.
info
(
"
addAbilityStageMonitor promise
"
);
console
.
info
(
'
addAbilityStageMonitor promise
'
);
});
```
...
...
@@ -915,13 +915,13 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\
let
abilityDelegator
;
let
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
'
);
});
```
...
...
@@ -951,13 +951,13 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
let
abilityDelegator
;
let
monitor
=
{
moduleName
:
"
moduleName
"
,
srcEntrance
:
"
srcEntrance
"
,
}
moduleName
:
'
moduleName
'
,
srcEntrance
:
'
srcEntrance
'
,
}
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
removeAbilityStageMonitor
(
monitor
).
then
(()
=>
{
console
.
info
(
"
removeAbilityStageMonitor promise
"
);
console
.
info
(
'
removeAbilityStageMonitor promise
'
);
});
```
...
...
@@ -982,17 +982,17 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<A
let
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
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
'
);
});
```
...
...
@@ -1023,17 +1023,17 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise
let
abilityDelegator
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
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
'
);
});
```
...
...
@@ -1060,16 +1060,16 @@ let abilityDelegator;
let
timeout
=
100
;
function
onAbilityCreateCallback
(
data
)
{
console
.
info
(
"
onAbilityCreateCallback
"
);
console
.
info
(
'
onAbilityCreateCallback
'
);
}
let
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
浏览文件 @
e53420cc
...
...
@@ -33,17 +33,17 @@ Ability监听器
import
AbilityDelegatorRegistry
from
'
@ohos.app.ability.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
浏览文件 @
e53420cc
...
...
@@ -31,15 +31,15 @@ AbilityRunningInfo模块提供对Ability运行的相关信息和状态的定义
import
abilitymanager
from
'
@ohos.app.ability.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
浏览文件 @
e53420cc
...
...
@@ -14,12 +14,12 @@
import
AbilityDelegatorRegistry
from
'
@ohos.app.ability.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
浏览文件 @
e53420cc
...
...
@@ -15,7 +15,7 @@ AccessibilityExtensionContext是AccessibilityExtensionAbility上下文环境,
在使用AccessibilityExtensionContext的功能前,需要通过AccessibilityExtensionAbility子类实例获取AccessibilityExtensionContex的实例。
```
ts
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
import
AccessibilityExtensionAbility
from
'
@ohos.application.AccessibilityExtensionAbility
'
;
let
axContext
;
class
EntryAbility
extends
AccessibilityExtensionAbility
{
onConnect
():
void
{
...
...
@@ -542,7 +542,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
{
...
...
@@ -585,7 +585,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
浏览文件 @
e53420cc
...
...
@@ -15,7 +15,7 @@
**示例:**
```
ts
import
appManager
from
"
@ohos.app.ability.appManager
"
import
appManager
from
'
@ohos.app.ability.appManager
'
;
function
getForegroundAppInfos
()
{
appManager
.
getForegroundApplications
((
error
,
data
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md
浏览文件 @
e53420cc
...
...
@@ -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
);
}
}
```
...
...
@@ -288,9 +288,9 @@ getProcessRunningInformation(): Promise\<Array\<ProcessRunningInformation>>;
```
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
));
});
```
...
...
@@ -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
));
}
})
```
...
...
@@ -343,7 +343,7 @@ killAllProcesses(): Promise\<void\>;
```
ts
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
killAllProcesses
()
applicationContext
.
killAllProcesses
()
;
```
## ApplicationContext.killAllProcesses<sup>9+</sup>
...
...
@@ -365,6 +365,6 @@ killAllProcesses(callback: AsyncCallback\<void\>);
```
ts
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
killAllProcesses
(
err
=>
{
console
.
error
(
"
killAllProcesses result:
"
+
JSON
.
stringify
(
err
));
})
console
.
error
(
'
killAllProcesses result:
'
+
JSON
.
stringify
(
err
));
})
;
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md
浏览文件 @
e53420cc
...
...
@@ -16,7 +16,7 @@
**示例:**
```
ts
import
appManager
from
"
@ohos.app.ability.appManager
"
;
import
appManager
from
'
@ohos.app.ability.appManager
'
;
let
applicationStateObserver
=
{
onForegroundApplicationChanged
(
appStateData
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-baseContext.md
浏览文件 @
e53420cc
...
...
@@ -22,7 +22,7 @@ import UIAbility from '@ohos.app.ability.UIAbility';
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
// EntryAbility onCreate, isStageMode: true
console
.
log
(
"
EntryAbility onCreate, isStageMode:
"
+
this
.
context
.
stageMode
);
console
.
log
(
'
EntryAbility onCreate, isStageMode:
'
+
this
.
context
.
stageMode
);
}
}
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md
浏览文件 @
e53420cc
...
...
@@ -60,7 +60,7 @@ createBundleContext(bundleName: string): Context;
```
ts
let
bundleContext
;
try
{
bundleContext
=
this
.
context
.
createBundleContext
(
"
com.example.test
"
);
bundleContext
=
this
.
context
.
createBundleContext
(
'
com.example.test
'
);
}
catch
(
error
)
{
console
.
log
(
'
createBundleContext failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
...
...
@@ -100,7 +100,7 @@ createModuleContext(moduleName: string): Context;
```
ts
let
moduleContext
;
try
{
moduleContext
=
this
.
context
.
createModuleContext
(
"
entry
"
);
moduleContext
=
this
.
context
.
createModuleContext
(
'
entry
'
);
}
catch
(
error
)
{
console
.
log
(
'
createModuleContext failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
...
...
@@ -139,7 +139,7 @@ createModuleContext(bundleName: string, moduleName: string): Context;
```
ts
let
moduleContext
;
try
{
moduleContext
=
this
.
context
.
createModuleContext
(
"
com.example.test
"
,
"
entry
"
);
moduleContext
=
this
.
context
.
createModuleContext
(
'
com.example.test
'
,
'
entry
'
);
}
catch
(
error
)
{
console
.
log
(
'
createModuleContext failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueCallback.md
浏览文件 @
e53420cc
...
...
@@ -19,14 +19,14 @@ Mission迁移完成后调用,返回迁移结果。
**示例:**
```
ts
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
;
let
continueDeviceInfo
=
{
srcDeviceId
:
"
123
"
,
dstDeviceId
:
"
456
"
,
srcDeviceId
:
'
123
'
,
dstDeviceId
:
'
456
'
,
missionId
:
123
,
wantParam
:
{
"
key
"
:
"
value
"
'
key
'
:
'
value
'
}
};
...
...
@@ -42,5 +42,5 @@ Mission迁移完成后调用,返回迁移结果。
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
console
.
log
(
'
continueMission finished
'
);
})
})
;
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-continueDeviceInfo.md
浏览文件 @
e53420cc
...
...
@@ -14,14 +14,14 @@
**示例:**
```
ts
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
import
distributedMissionManager
from
'
@ohos.distributedMissionManager
'
;
let
continueDeviceInfo
=
{
srcDeviceId
:
"
123
"
,
dstDeviceId
:
"
456
"
,
srcDeviceId
:
'
123
'
,
dstDeviceId
:
'
456
'
,
missionId
:
123
,
wantParam
:
{
"
key
"
:
"
value
"
'
key
'
:
'
value
'
}
};
...
...
@@ -37,5 +37,5 @@
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
console
.
log
(
'
continueMission finished
'
);
})
})
;
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-errorObserver.md
浏览文件 @
e53420cc
...
...
@@ -25,10 +25,10 @@ let observer = {
onUnhandledException
(
errorMsg
)
{
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
);
}
}
}
;
try
{
errorManager
.
on
(
"
error
"
,
observer
);
errorManager
.
on
(
'
error
'
,
observer
);
}
catch
(
error
)
{
console
.
log
(
'
registerErrorObserver
'
+
'
failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-eventHub.md
浏览文件 @
e53420cc
...
...
@@ -16,11 +16,11 @@ import UIAbility from '@ohos.app.ability.UIAbility';
export
default
class
EntryAbility
extends
UIAbility
{
eventFunc
(){
console
.
log
(
"
eventFunc is called
"
);
console
.
log
(
'
eventFunc is called
'
);
}
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc
);
this
.
context
.
eventHub
.
on
(
'
myEvent
'
,
this
.
eventFunc
);
}
}
```
...
...
@@ -47,19 +47,19 @@ import UIAbility from '@ohos.app.ability.UIAbility';
export
default
class
EntryAbility
extends
UIAbility
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc
);
this
.
context
.
eventHub
.
on
(
'
myEvent
'
,
this
.
eventFunc
);
// 支持使用匿名函数订阅事件
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
()
=>
{
console
.
log
(
"
call anonymous eventFunc
"
);
this
.
context
.
eventHub
.
on
(
'
myEvent
'
,
()
=>
{
console
.
log
(
'
call anonymous eventFunc
'
);
});
// 结果:
// eventFunc is called
// call anonymous eventFunc
this
.
context
.
eventHub
.
emit
(
"
myEvent
"
);
this
.
context
.
eventHub
.
emit
(
'
myEvent
'
);
}
eventFunc
()
{
console
.
log
(
"
eventFunc is called
"
);
console
.
log
(
'
eventFunc is called
'
);
}
}
```
...
...
@@ -88,19 +88,19 @@ import UIAbility from '@ohos.app.ability.UIAbility';
export
default
class
EntryAbility
extends
UIAbility
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc1
);
this
.
context
.
eventHub
.
off
(
"
myEvent
"
,
this
.
eventFunc1
);
// 取消eventFunc1对myEvent事件的订阅
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc1
);
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc2
);
this
.
context
.
eventHub
.
off
(
"
myEvent
"
);
// 取消eventFunc1和eventFunc2对myEvent事件的订阅
this
.
context
.
eventHub
.
on
(
'
myEvent
'
,
this
.
eventFunc1
);
this
.
context
.
eventHub
.
off
(
'
myEvent
'
,
this
.
eventFunc1
);
// 取消eventFunc1对myEvent事件的订阅
this
.
context
.
eventHub
.
on
(
'
myEvent
'
,
this
.
eventFunc1
);
this
.
context
.
eventHub
.
on
(
'
myEvent
'
,
this
.
eventFunc2
);
this
.
context
.
eventHub
.
off
(
'
myEvent
'
);
// 取消eventFunc1和eventFunc2对myEvent事件的订阅
}
eventFunc1
()
{
console
.
log
(
"
eventFunc1 is called
"
);
console
.
log
(
'
eventFunc1 is called
'
);
}
eventFunc2
()
{
console
.
log
(
"
eventFunc2 is called
"
);
console
.
log
(
'
eventFunc2 is called
'
);
}
}
```
...
...
@@ -127,20 +127,20 @@ import UIAbility from '@ohos.app.ability.UIAbility';
export
default
class
EntryAbility
extends
UIAbility
{
onForeground
()
{
this
.
context
.
eventHub
.
on
(
"
myEvent
"
,
this
.
eventFunc
);
this
.
context
.
eventHub
.
on
(
'
myEvent
'
,
this
.
eventFunc
);
// 结果:
// eventFunc is called,undefined,undefined
this
.
context
.
eventHub
.
emit
(
"
myEvent
"
);
this
.
context
.
eventHub
.
emit
(
'
myEvent
'
);
// 结果:
// eventFunc is called,1,undefined
this
.
context
.
eventHub
.
emit
(
"
myEvent
"
,
1
);
this
.
context
.
eventHub
.
emit
(
'
myEvent
'
,
1
);
// 结果:
// eventFunc is called,1,2
this
.
context
.
eventHub
.
emit
(
"
myEvent
"
,
1
,
2
);
this
.
context
.
eventHub
.
emit
(
'
myEvent
'
,
1
,
2
);
}
eventFunc
(
argOne
,
argTwo
)
{
console
.
log
(
"
eventFunc is called,
"
+
argOne
+
"
,
"
+
argTwo
);
console
.
log
(
'
eventFunc is called,
'
+
argOne
+
'
,
'
+
argTwo
);
}
}
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md
浏览文件 @
e53420cc
...
...
@@ -66,11 +66,11 @@ import UIAbility from '@ohos.app.ability.UIAbility';
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
"
[Demo] EntryAbility onCreate
"
);
console
.
log
(
'
[Demo] EntryAbility onCreate
'
);
let
wantExt
=
{
deviceId
:
""
,
bundleName
:
"
com.example.TheServiceExtension
"
,
abilityName
:
"
TheServiceExtension
"
,
deviceId
:
''
,
bundleName
:
'
com.example.TheServiceExtension
'
,
abilityName
:
'
TheServiceExtension
'
,
};
this
.
context
.
startServiceExtensionAbility
(
wantExt
);
}
...
...
@@ -85,8 +85,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
;
}
...
...
@@ -94,20 +94,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
浏览文件 @
e53420cc
...
...
@@ -27,7 +27,7 @@ ExtensionRunningInfo模块封装了Extension运行的相关信息,可以通过
**示例:**
```
ts
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
import
abilityManager
from
'
@ohos.app.ability.abilityManager
'
;
let
upperLimit
=
1
;
function
getExtensionInfos
()
{
...
...
@@ -40,13 +40,13 @@ function getExtensionInfos() {
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
));
}
});
}
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md
浏览文件 @
e53420cc
...
...
@@ -22,8 +22,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
;
...
...
@@ -56,13 +56,13 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
// 当触发卡片message事件时,执行startAbility
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
"
, message:
"
+
message
);
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
'
, message:
'
+
message
);
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.formstartability
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
''
,
bundleName
:
'
com.example.formstartability
'
,
abilityName
:
'
EntryAbility
'
,
parameters
:
{
"
message
"
:
message
'
message
'
:
message
}
};
this
.
context
.
startAbility
(
want
,
(
error
,
data
)
=>
{
...
...
@@ -106,19 +106,19 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
// 当触发卡片message事件时,执行startAbility
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
"
, message:
"
+
message
);
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
'
, message:
'
+
message
);
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.formstartability
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
''
,
bundleName
:
'
com.example.formstartability
'
,
abilityName
:
'
EntryAbility
'
,
parameters
:
{
"
message
"
:
message
'
message
'
:
message
}
};
this
.
context
.
startAbility
(
want
).
then
(()
=>
{
console
.
info
(
"
StartAbility Success
"
);
console
.
info
(
'
StartAbility Success
'
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
StartAbility failed
"
);
console
.
info
(
'
StartAbility failed
'
);
});
}
};
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionCallbacks.md
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -19,14 +19,14 @@
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.missionManager
'
;
try
{
missionManager
.
getMissionInfo
(
""
,
1
,
(
error
,
data
)
=>
{
missionManager
.
getMissionInfo
(
''
,
1
,
(
error
,
data
)
=>
{
if
(
error
.
code
)
{
// 处理业务逻辑错误
console
.
log
(
"
getMissionInfo failed, error.code:
"
+
JSON
.
stringify
(
error
.
code
)
+
"
error.message:
"
+
JSON
.
stringify
(
error
.
message
));
console
.
log
(
'
getMissionInfo failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
return
;
}
...
...
@@ -40,6 +40,6 @@ try {
console
.
log
(
'
getMissionInfo continuable is:
'
+
JSON
.
stringify
(
data
.
continuable
));
});
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionListener.md
浏览文件 @
e53420cc
...
...
@@ -16,32 +16,32 @@
**示例:**
```
ts
import
missionManager
from
'
@ohos.app.ability.missionManager
'
import
missionManager
from
'
@ohos.app.ability.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
));
}
};
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
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionParameter.md
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -25,28 +25,28 @@
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
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
err
,
snapshot
)
=>
{
missionManager
.
getMissionSnapShot
(
''
,
id
,
(
err
,
snapshot
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
"
getMissionInfos failed, err.code:
"
+
JSON
.
stringify
(
err
.
code
)
+
"
err.message:
"
+
JSON
.
stringify
(
err
.
message
));
console
.
log
(
'
getMissionInfos failed, err.code:
'
+
JSON
.
stringify
(
err
.
code
)
+
'
err.message:
'
+
JSON
.
stringify
(
err
.
message
));
return
;
}
// 执行正常业务
console
.
log
(
"
bundleName =
"
+
snapshot
.
ability
.
bundleName
);
console
.
log
(
'
bundleName =
'
+
snapshot
.
ability
.
bundleName
);
})
})
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
console
.
log
(
'
error:
'
+
paramError
.
code
+
'
,
'
+
paramError
.
message
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-processInformation.md
浏览文件 @
e53420cc
...
...
@@ -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
浏览文件 @
e53420cc
...
...
@@ -16,7 +16,7 @@ ServiceExtensionContext模块提供ServiceExtensionAbility具有的能力,包
```
ts
import
ServiceExtensionAbility
from
'
@ohos.app.ability.ServiceExtensionAbility
'
;
let
context
=
undefined
;
let
context
;
class
EntryAbility
extends
ServiceExtensionAbility
{
onCreate
()
{
context
=
this
.
context
;
// 获取ServiceExtensionContext
...
...
@@ -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.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
windowMode
:
0
...
...
@@ -291,9 +291,9 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
...
...
@@ -368,9 +368,9 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -454,9 +454,9 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -519,9 +519,9 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
...
...
@@ -585,9 +585,9 @@ startServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
...
...
@@ -651,9 +651,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
...
...
@@ -722,9 +722,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
...
...
@@ -781,9 +781,9 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
...
...
@@ -844,9 +844,9 @@ stopServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
...
...
@@ -906,9 +906,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
...
...
@@ -974,9 +974,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
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,16 +1179,16 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
)
},
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
}
}
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
;
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
)
;
},
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
;
}
}
;
let
connection
=
null
;
try
{
...
...
@@ -1355,14 +1355,14 @@ startAbilityByCall(want: Want): Promise<Caller>;
后台启动:
```
ts
let
caller
=
undefined
;
let
caller
;
// 后台启动Ability,不配置parameters
let
wantBackground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
EntryAbility
'
,
deviceId
:
''
};
try
{
...
...
@@ -1386,16 +1386,16 @@ startAbilityByCall(want: Want): Promise<Caller>;
前台启动:
```
ts
let
caller
=
undefined
;
let
caller
;
// 前台启动Ability,将parameters中的
"ohos.aafwk.param.callAbilityToForeground"
配置为true
// 前台启动Ability,将parameters中的
'ohos.aafwk.param.callAbilityToForeground'
配置为true
let
wantForeground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
""
,
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
EntryAbility
'
,
deviceId
:
''
,
parameters
:
{
"
ohos.aafwk.param.callAbilityToForeground
"
:
true
'
ohos.aafwk.param.callAbilityToForeground
'
:
true
}
};
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md
浏览文件 @
e53420cc
...
...
@@ -19,13 +19,13 @@
**示例:**
```
ts
import
AbilityDelegatorRegistry
from
"
@ohos.app.ability.abilityDelegatorRegistry
"
;
import
AbilityDelegatorRegistry
from
'
@ohos.app.ability.abilityDelegatorRegistry
'
;
let
abilityDelegator
;
let
cmd
=
"
cmd
"
;
let
cmd
=
'
cmd
'
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
data
:
any
)
=>
{
console
.
info
(
"
executeShellCommand callback, result:
"
,
err
);
console
.
info
(
"
executeShellCommand callback, data:
"
,
data
);
console
.
info
(
'
executeShellCommand callback, result:
'
,
err
);
console
.
info
(
'
executeShellCommand callback, data:
'
,
data
);
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
浏览文件 @
e53420cc
...
...
@@ -62,8 +62,8 @@ startAbility(want: Want, callback: AsyncCallback<void>): void;
```
ts
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
bundleName
:
'
com.example.myapp
'
,
abilityName
:
'
MyAbility
'
};
try
{
...
...
@@ -127,9 +127,9 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
windowMode
:
0
...
...
@@ -201,8 +201,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
,
...
...
@@ -271,9 +271,9 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>):
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
...
...
@@ -285,7 +285,7 @@ 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
)
{
// 处理入参错误异常
...
...
@@ -340,9 +340,9 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
windowMode
:
0
,
...
...
@@ -357,7 +357,7 @@ 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
)
{
// 处理入参错误异常
...
...
@@ -419,8 +419,8 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes
```
ts
let
want
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
windowMode
:
0
,
...
...
@@ -430,7 +430,7 @@ try {
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
)
=>
{
// 处理业务逻辑错误
...
...
@@ -491,9 +491,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
...
...
@@ -506,8 +506,8 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC
return
;
}
// 执行正常业务
console
.
log
(
"
startAbilityForResultWithAccount succeed, result.resultCode =
"
+
result
.
resultCode
+
'
result.want =
'
+
JSON
.
stringify
(
result
.
want
))
console
.
log
(
'
startAbilityForResultWithAccount succeed, result.resultCode =
'
+
result
.
resultCode
+
'
result.want =
'
+
JSON
.
stringify
(
result
.
want
))
;
});
}
catch
(
paramError
)
{
// 处理入参错误异常
...
...
@@ -565,9 +565,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -583,7 +583,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
return
;
}
// 执行正常业务
console
.
log
(
"
startAbilityForResultWithAccount succeed
"
)
console
.
log
(
'
startAbilityForResultWithAccount succeed
'
);
});
}
catch
(
paramError
)
{
// 处理入参错误异常
...
...
@@ -646,9 +646,9 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -659,8 +659,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
)
=>
{
// 处理业务逻辑错误
...
...
@@ -707,9 +707,9 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
ServiceExtensionAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
ServiceExtensionAbility
'
};
try
{
...
...
@@ -763,9 +763,9 @@ startServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
ServiceExtensionAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
ServiceExtensionAbility
'
};
try
{
...
...
@@ -823,9 +823,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
ServiceExtensionAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
ServiceExtensionAbility
'
};
let
accountId
=
100
;
...
...
@@ -883,9 +883,9 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
ServiceExtensionAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
ServiceExtensionAbility
'
};
let
accountId
=
100
;
...
...
@@ -939,9 +939,9 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
ServiceExtensionAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
ServiceExtensionAbility
'
};
try
{
...
...
@@ -994,9 +994,9 @@ stopServiceExtensionAbility(want: Want): Promise\<void>;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
ServiceExtensionAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
ServiceExtensionAbility
'
};
try
{
...
...
@@ -1053,9 +1053,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
ServiceExtensionAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
ServiceExtensionAbility
'
};
let
accountId
=
100
;
...
...
@@ -1112,9 +1112,9 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
ServiceExtensionAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
ServiceExtensionAbility
'
};
let
accountId
=
100
;
...
...
@@ -1260,15 +1260,15 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi
```
ts
let
want
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
}
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
}
;
let
resultCode
=
100
;
// 返回给接口调用方AbilityResult信息
let
abilityResult
=
{
want
,
resultCode
}
}
;
try
{
this
.
context
.
terminateSelfWithResult
(
abilityResult
,
(
error
)
=>
{
...
...
@@ -1324,15 +1324,15 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>;
```
ts
let
want
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
}
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
}
;
let
resultCode
=
100
;
// 返回给接口调用方AbilityResult信息
let
abilityResult
=
{
want
,
resultCode
}
}
;
try
{
this
.
context
.
terminateSelfWithResult
(
abilityResult
)
...
...
@@ -1386,9 +1386,9 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
ServiceExtensionAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
ServiceExtensionAbility
'
};
let
options
=
{
onConnect
(
elementName
,
remote
)
{
...
...
@@ -1400,7 +1400,7 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
}
}
}
;
let
connection
=
null
;
try
{
...
...
@@ -1452,9 +1452,9 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
ServiceExtensionAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
ServiceExtensionAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -1467,7 +1467,7 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
}
}
}
;
let
connection
=
null
;
try
{
...
...
@@ -1628,14 +1628,14 @@ startAbilityByCall(want: Want): Promise<Caller>;
后台启动:
```
ts
let
caller
=
undefined
;
let
caller
;
// 后台启动Ability,不配置parameters
let
wantBackground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
""
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
EntryAbility
'
,
deviceId
:
''
};
try
{
...
...
@@ -1659,16 +1659,16 @@ startAbilityByCall(want: Want): Promise<Caller>;
前台启动:
```
ts
let
caller
=
undefined
;
let
caller
;
// 前台启动Ability,将parameters中的
"ohos.aafwk.param.callAbilityToForeground"
配置为true
// 前台启动Ability,将parameters中的
'ohos.aafwk.param.callAbilityToForeground'
配置为true
let
wantForeground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
EntryAbility
"
,
deviceId
:
""
,
bundleName
:
'
com.example.myservice
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
EntryAbility
'
,
deviceId
:
''
,
parameters
:
{
"
ohos.aafwk.param.callAbilityToForeground
"
:
true
'
ohos.aafwk.param.callAbilityToForeground
'
:
true
}
};
...
...
@@ -1737,9 +1737,9 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
...
...
@@ -1810,9 +1810,9 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -1885,9 +1885,9 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
```
ts
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
EntryAbility
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
accountId
=
100
;
let
options
=
{
...
...
@@ -1930,7 +1930,7 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void;
**示例:**
```
ts
this
.
context
.
setMissionLabel
(
"
test
"
,
(
result
)
=>
{
this
.
context
.
setMissionLabel
(
'
test
'
,
(
result
)
=>
{
console
.
log
(
'
setMissionLabel:
'
+
JSON
.
stringify
(
result
));
});
```
...
...
@@ -1965,7 +1965,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
));
...
...
@@ -2012,7 +2012,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
);
...
...
@@ -2065,7 +2065,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
(()
=>
{
...
...
@@ -2157,9 +2157,9 @@ requestDialogService(want: Want, result: AsyncCallback<dialogRequest.RequestR
import
dialogRequest
from
'
@ohos.app.ability.dialogRequest
'
;
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
AuthAccountServiceExtension
"
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
AuthAccountServiceExtension
'
};
try
{
...
...
@@ -2171,7 +2171,7 @@ requestDialogService(want: Want, result: AsyncCallback<dialogRequest.RequestR
return
;
}
// 执行正常业务
console
.
log
(
"
requestDialogService succeed, result =
"
+
JSON
.
stringify
(
result
));
console
.
log
(
'
requestDialogService succeed, result =
'
+
JSON
.
stringify
(
result
));
});
}
catch
(
paramError
)
{
// 处理入参错误异常
...
...
@@ -2212,15 +2212,15 @@ requestDialogService(want: Want): Promise<dialogRequest.RequestResult>;
import
dialogRequest
from
'
@ohos.app.ability.dialogRequest
'
;
let
want
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
AuthAccountServiceExtension
"
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
AuthAccountServiceExtension
'
};
try
{
this
.
context
.
requestDialogService
(
want
)
.
then
((
result
)
=>
{
// 执行正常业务
console
.
log
(
"
requestDialogService succeed, result =
"
+
JSON
.
stringify
(
result
));
console
.
log
(
'
requestDialogService succeed, result =
'
+
JSON
.
stringify
(
result
));
})
.
catch
((
error
)
=>
{
// 处理业务逻辑错误
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md
浏览文件 @
e53420cc
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录