Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
21529cb2
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
21529cb2
编写于
2月 15, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 15, 2023
浏览文件
操作
浏览文件
下载
差异文件
!14349 资料描述优化
Merge pull request !14349 from mingxihua/OpenHarmony-3.2-Beta5
上级
f2a4b28a
5eba20d7
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
360 addition
and
335 deletion
+360
-335
zh-cn/application-dev/reference/apis/js-apis-ability-context.md
...application-dev/reference/apis/js-apis-ability-context.md
+85
-76
zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md
...tion-dev/reference/apis/js-apis-ability-featureAbility.md
+13
-7
zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md
...ion-dev/reference/apis/js-apis-ability-particleAbility.md
+4
-4
zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
...reference/apis/js-apis-app-ability-environmentCallback.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md
...on-dev/reference/apis/js-apis-app-ability-errorManager.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
...-dev/reference/apis/js-apis-app-ability-missionManager.md
+30
-30
zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
...ation-dev/reference/apis/js-apis-app-ability-uiAbility.md
+11
-11
zh-cn/application-dev/reference/apis/js-apis-application-ability.md
...ication-dev/reference/apis/js-apis-application-ability.md
+9
-9
zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
...ence/apis/js-apis-application-abilityDelegatorRegistry.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
...ence/apis/js-apis-application-abilityLifecycleCallback.md
+3
-2
zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md
...-dev/reference/apis/js-apis-application-abilityManager.md
+2
-2
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-environmentCallback.md
...reference/apis/js-apis-application-environmentCallback.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-application-errorManager.md
...on-dev/reference/apis/js-apis-application-errorManager.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md
...-dev/reference/apis/js-apis-application-missionManager.md
+32
-32
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md
...reference/apis/js-apis-inner-ability-dataAbilityHelper.md
+30
-30
zh-cn/application-dev/reference/apis/js-apis-inner-app-context.md
...plication-dev/reference/apis/js-apis-inner-app-context.md
+56
-56
zh-cn/application-dev/reference/apis/js-apis-inner-app-processInfo.md
...ation-dev/reference/apis/js-apis-inner-app-processInfo.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegatorArgs.md
...ce/apis/js-apis-inner-application-abilityDelegatorArgs.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md
...eference/apis/js-apis-inner-application-abilityMonitor.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md
...ence/apis/js-apis-inner-application-applicationContext.md
+6
-6
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md
...erence/apis/js-apis-inner-application-extensionContext.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md
...ference/apis/js-apis-inner-application-missionSnapshot.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md
...apis/js-apis-inner-application-serviceExtensionContext.md
+38
-38
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
...erence/apis/js-apis-inner-application-uiAbilityContext.md
+12
-3
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-ability-context.md
浏览文件 @
21529cb2
...
...
@@ -64,7 +64,7 @@ startAbility(want: Want, callback: AsyncCallback<void>): void;
**示例:**
```
ts
var
want
=
{
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
};
...
...
@@ -106,7 +106,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| options |
[
StartOptions
](
js-apis-app
lication
-startOptions.md
)
| 是 | 启动Ability所携带的参数。 |
| options |
[
StartOptions
](
js-apis-app
-ability
-startOptions.md
)
| 是 | 启动Ability所携带的参数。 |
| callback | AsyncCallback
<
void
>
| 是 | callback形式返回启动结果。 |
**错误码:**
...
...
@@ -119,12 +119,12 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
options
=
{
let
options
=
{
windowMode
:
0
};
...
...
@@ -164,7 +164,7 @@ startAbility(want: Want, options?: StartOptions): Promise<void>;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| options |
[
StartOptions
](
js-apis-app
lication
-startOptions.md
)
| 否 | 启动Ability所携带的参数。 |
| options |
[
StartOptions
](
js-apis-app
-ability
-startOptions.md
)
| 否 | 启动Ability所携带的参数。 |
**返回值:**
...
...
@@ -182,11 +182,11 @@ startAbility(want: Want, options?: StartOptions): Promise<void>;
**示例:**
```
ts
var
want
=
{
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
};
var
options
=
{
let
options
=
{
windowMode
:
0
,
};
...
...
@@ -213,7 +213,10 @@ startAbility(want: Want, options?: StartOptions): Promise<void>;
startAbilityForResult(want: Want, callback: AsyncCallback
<
AbilityResult
>
): void;
启动一个Ability。Ability被启动后,正常情况下可通过调用
[
terminateSelfWithResult
](
#abilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用者。异常情况下比如杀死Ability会返回异常信息给调用者(callback形式)。
启动一个Ability。Ability被启动后,有如下情况(callback形式):
-
正常情况下可通过调用
[
terminateSelfWithResult
](
#abilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用方。
-
异常情况下比如杀死Ability会返回异常信息给调用方, 异常信息中resultCode为-1。
-
如果被启动的Ability模式是单实例模式, 不同应用多次调用该接口启动这个Ability,当这个Ability调用
[
terminateSelfWithResult
](
#abilitycontextterminateselfwithresult
)
接口使之终止时,只将正常结果返回给最后一个调用方, 其它调用方返回异常信息, 异常信息中resultCode为-1。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
...
...
@@ -239,7 +242,7 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>):
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
...
...
@@ -268,7 +271,10 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>):
startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
<
AbilityResult
>
): void;
启动一个Ability。Ability被启动后,正常情况下可通过调用
[
terminateSelfWithResult
](
#abilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用者。异常情况下比如杀死Ability会返回异常信息给调用者(callback形式)。
启动一个Ability。Ability被启动后,有如下情况(callback形式):
-
正常情况下可通过调用
[
terminateSelfWithResult
](
#abilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用方。
-
异常情况下比如杀死Ability会返回异常信息给调用方, 异常信息中resultCode为-1。
-
如果被启动的Ability模式是单实例模式, 不同应用多次调用该接口启动这个Ability,当这个Ability调用
[
terminateSelfWithResult
](
#abilitycontextterminateselfwithresult
)
接口使之终止时,只将正常结果返回给最后一个调用方, 其它调用方返回异常信息, 异常信息中resultCode为-1。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
...
...
@@ -282,7 +288,7 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| options |
[
StartOptions
](
js-apis-app
lication
-startOptions.md
)
| 是 | 启动Ability所携带的参数。 |
| options |
[
StartOptions
](
js-apis-app
-ability
-startOptions.md
)
| 是 | 启动Ability所携带的参数。 |
| callback | AsyncCallback
<
[AbilityResult](js-apis-inner-ability-abilityResult.md)
>
| 是 | 执行结果回调函数。 |
**错误码:**
...
...
@@ -295,12 +301,12 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
options
=
{
let
options
=
{
windowMode
:
0
,
};
...
...
@@ -328,7 +334,10 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
startAbilityForResult(want: Want, options?: StartOptions): Promise
<
AbilityResult
>
;
启动一个Ability。Ability被启动后,正常情况下可通过调用
[
terminateSelfWithResult
](
#abilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用者。异常情况下比如杀死Ability会返回异常信息给调用者(promise形式)。
启动一个Ability。Ability被启动后,有如下情况(promise形式):
-
正常情况下可通过调用
[
terminateSelfWithResult
](
#abilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用方。
-
异常情况下比如杀死Ability会返回异常信息给调用方, 异常信息中resultCode为-1。
-
如果被启动的Ability模式是单实例模式, 不同应用多次调用该接口启动这个Ability,当这个Ability调用
[
terminateSelfWithResult
](
#abilitycontextterminateselfwithresult
)
接口使之终止时,只将正常结果返回给最后一个调用方, 其它调用方返回异常信息, 异常信息中resultCode为-1。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
...
...
@@ -342,7 +351,7 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| options |
[
StartOptions
](
js-apis-app
lication
-startOptions.md
)
| 否 | 启动Ability所携带的参数。 |
| options |
[
StartOptions
](
js-apis-app
-ability
-startOptions.md
)
| 否 | 启动Ability所携带的参数。 |
**返回值:**
...
...
@@ -361,11 +370,11 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes
**示例:**
```
ts
var
want
=
{
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
};
var
options
=
{
let
options
=
{
windowMode
:
0
,
};
...
...
@@ -422,12 +431,12 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
startAbilityForResultWithAccount
(
want
,
accountId
,
(
error
,
result
)
=>
{
...
...
@@ -472,7 +481,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| accountId | number | 是 | 系统帐号的帐号ID,详情参考
[
getCreatedOsAccountsCount
](
js-apis-osAccount.md#getosaccountlocalidfromprocess
)
。 |
| options |
[
StartOptions
](
js-apis-app
lication
-startOptions.md
)
| 是 | 启动Ability所携带的参数。 |
| options |
[
StartOptions
](
js-apis-app
-ability
-startOptions.md
)
| 是 | 启动Ability所携带的参数。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 启动Ability的回调函数。 |
**错误码:**
...
...
@@ -485,13 +494,13 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
var
options
=
{
let
accountId
=
100
;
let
options
=
{
windowMode
:
0
};
...
...
@@ -538,7 +547,7 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| accountId | number | 是 | 系统帐号的帐号ID,详情参考
[
getCreatedOsAccountsCount
](
js-apis-osAccount.md#getosaccountlocalidfromprocess
)
。 |
| options |
[
StartOptions
](
js-apis-app
lication
-startOptions.md
)
| 否 | 启动Ability所携带的参数。 |
| options |
[
StartOptions
](
js-apis-app
-ability
-startOptions.md
)
| 否 | 启动Ability所携带的参数。 |
**返回值:**
...
...
@@ -556,13 +565,13 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
var
options
=
{
let
accountId
=
100
;
let
options
=
{
windowMode
:
0
};
...
...
@@ -611,7 +620,7 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
...
...
@@ -661,7 +670,7 @@ startServiceExtensionAbility(want: Want): Promise\<void>;
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
...
...
@@ -715,12 +724,12 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
startServiceExtensionAbilityWithAccount
(
want
,
accountId
,
(
error
)
=>
{
...
...
@@ -769,12 +778,12 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
startServiceExtensionAbilityWithAccount
(
want
,
accountId
)
...
...
@@ -820,7 +829,7 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
...
...
@@ -870,7 +879,7 @@ stopServiceExtensionAbility(want: Want): Promise\<void>;
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
...
...
@@ -924,12 +933,12 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
stopServiceExtensionAbilityWithAccount
(
want
,
accountId
,
(
error
)
=>
{
...
...
@@ -978,12 +987,12 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
stopServiceExtensionAbilityWithAccount
(
want
,
accountId
)
...
...
@@ -1100,13 +1109,13 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi
**示例:**
```
ts
var
want
=
{
let
want
=
{
bundleName
:
"
com.extreme.myapplication
"
,
abilityName
:
"
SecondAbility
"
}
var
resultCode
=
100
;
let
resultCode
=
100
;
// 返回给接口调用方AbilityResult信息
var
abilityResult
=
{
let
abilityResult
=
{
want
,
resultCode
}
...
...
@@ -1162,13 +1171,13 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>;
**示例:**
```
ts
var
want
=
{
let
want
=
{
bundleName
:
"
com.extreme.myapplication
"
,
abilityName
:
"
SecondAbility
"
}
var
resultCode
=
100
;
let
resultCode
=
100
;
// 返回给接口调用方AbilityResult信息
var
abilityResult
=
{
let
abilityResult
=
{
want
,
resultCode
}
...
...
@@ -1224,18 +1233,18 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
options
=
{
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
)
},
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
}
}
var
connection
=
null
;
let
connection
=
null
;
try
{
connection
=
this
.
context
.
connectServiceExtensionAbility
(
want
,
options
);
}
catch
(
paramError
)
{
...
...
@@ -1282,19 +1291,19 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
var
options
=
{
let
accountId
=
100
;
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
)
},
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
}
}
var
connection
=
null
;
let
connection
=
null
;
try
{
connection
=
this
.
context
.
connectServiceExtensionAbilityWithAccount
(
want
,
accountId
,
options
);
}
catch
(
paramError
)
{
...
...
@@ -1335,7 +1344,7 @@ disconnectServiceExtensionAbility(connection: number): Promise\<void>;
```
ts
// connection为connectServiceExtensionAbility中的返回值
var
connection
=
1
;
let
connection
=
1
;
try
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
)
...
...
@@ -1381,7 +1390,7 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\<vo
```
ts
// connection为connectServiceExtensionAbility中的返回值
var
connection
=
1
;
let
connection
=
1
;
try
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
,
(
error
)
=>
{
...
...
@@ -1433,10 +1442,10 @@ startAbilityByCall(want: Want): Promise<Caller>;
后台启动:
```
ts
var
caller
=
undefined
;
let
caller
=
undefined
;
// 后台启动Ability,不配置parameters
var
wantBackground
=
{
let
wantBackground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
MainAbility
"
,
...
...
@@ -1464,10 +1473,10 @@ startAbilityByCall(want: Want): Promise<Caller>;
前台启动:
```
ts
var
caller
=
undefined
;
let
caller
=
undefined
;
// 前台启动Ability,将parameters中的"ohos.aafwk.param.callAbilityToForeground"配置为true
var
wantForeground
=
{
let
wantForeground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
MainAbility
"
,
...
...
@@ -1530,12 +1539,12 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
startAbilityWithAccount
(
want
,
accountId
,
(
error
)
=>
{
...
...
@@ -1579,7 +1588,7 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| accountId | number | 是 | 系统帐号的帐号ID,详情参考
[
getCreatedOsAccountsCount
](
js-apis-osAccount.md#getosaccountlocalidfromprocess
)
。|
| options |
[
StartOptions
](
js-apis-app
lication
-startOptions.md
)
| 是 | 启动Ability所携带的参数。 |
| options |
[
StartOptions
](
js-apis-app
-ability
-startOptions.md
)
| 是 | 启动Ability所携带的参数。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 启动Ability的回调函数。 |
**错误码:**
...
...
@@ -1592,13 +1601,13 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
var
options
=
{
let
accountId
=
100
;
let
options
=
{
windowMode
:
0
};
...
...
@@ -1644,7 +1653,7 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| accountId | number | 是 | 系统帐号的帐号ID,详情参考
[
getCreatedOsAccountsCount
](
js-apis-osAccount.md#getosaccountlocalidfromprocess
)
。 |
| options |
[
StartOptions
](
js-apis-app
lication
-startOptions.md
)
| 否 | 启动Ability所携带的参数。 |
| options |
[
StartOptions
](
js-apis-app
-ability
-startOptions.md
)
| 否 | 启动Ability所携带的参数。 |
**错误码:**
...
...
@@ -1656,13 +1665,13 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
var
options
=
{
let
accountId
=
100
;
let
options
=
{
windowMode
:
0
};
...
...
@@ -1758,9 +1767,9 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void;
```
ts
import
image
from
'
@ohos.multimedia.image
'
;
var
imagePixelMap
;
var
color
=
new
ArrayBuffer
(
0
);
var
initializationOptions
=
{
let
imagePixelMap
;
let
color
=
new
ArrayBuffer
(
0
);
let
initializationOptions
=
{
size
:
{
height
:
100
,
width
:
100
...
...
@@ -1805,9 +1814,9 @@ setMissionIcon(icon: image.PixelMap): Promise\<void>;
```
ts
import
image
from
'
@ohos.multimedia.image
'
;
var
imagePixelMap
;
var
color
=
new
ArrayBuffer
(
0
);
var
initializationOptions
=
{
let
imagePixelMap
;
let
color
=
new
ArrayBuffer
(
0
);
let
initializationOptions
=
{
size
:
{
height
:
100
,
width
:
100
...
...
@@ -1845,7 +1854,7 @@ restoreWindowStage(localStorage: LocalStorage) : void;
**示例:**
```
ts
var
storage
=
new
LocalStorage
();
let
storage
=
new
LocalStorage
();
this
.
context
.
restoreWindowStage
(
storage
);
```
...
...
@@ -1866,6 +1875,6 @@ isTerminating(): boolean;
**示例:**
```
ts
var
isTerminating
=
this
.
context
.
isTerminating
();
let
isTerminating
=
this
.
context
.
isTerminating
();
console
.
log
(
'
ability state :
'
+
isTerminating
);
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md
浏览文件 @
21529cb2
...
...
@@ -139,7 +139,7 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
```
...
...
@@ -148,7 +148,10 @@ var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(
startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback
\<
AbilityResult>): void
启动一个Ability。Ability被启动后,正常情况下可通过调用
[
terminateSelfWithResult
](
#featureabilityterminateselfwithresult7
)
接口使之终止并且返回结果给调用者。异常情况下比如杀死Ability会返回异常信息给调用者(callback形式)。
启动一个Ability。Ability被启动后,有如下情况(callback形式):
-
正常情况下可通过调用
[
terminateSelfWithResult
](
#featureabilityterminateselfwithresult7
)
接口使之终止并且返回结果给调用方。
-
异常情况下比如杀死Ability会返回异常信息给调用方, 异常信息中resultCode为-1。
-
如果被启动的Ability模式是单实例模式, 不同应用多次调用该接口启动这个Ability,当这个Ability调用
[
terminateSelfWithResult
](
#featureabilityterminateselfwithresult7
)
接口使之终止时,只将正常结果返回给最后一个调用方, 其它调用方返回异常信息, 异常信息中resultCode为-1。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
...
...
@@ -194,7 +197,10 @@ featureAbility.startAbilityForResult(
startAbilityForResult(parameter: StartAbilityParameter): Promise
\<
AbilityResult>
启动一个Ability。Ability被启动后,正常情况下可通过调用
[
terminateSelfWithResult
](
#featureabilityterminateselfwithresult7
)
接口使之终止并且返回结果给调用者。异常情况下比如杀死Ability会返回异常信息给调用者(Promise形式)。
启动一个Ability。Ability被启动后,有如下情况(Promise形式):
-
正常情况下可通过调用
[
terminateSelfWithResult
](
#featureabilityterminateselfwithresult7
)
接口使之终止并且返回结果给调用方。
-
异常情况下比如杀死Ability会返回异常信息给调用方, 异常信息中resultCode为-1。
-
如果被启动的Ability模式是单实例模式, 不同应用多次调用该接口启动这个Ability,当这个Ability调用
[
terminateSelfWithResult
](
#featureabilityterminateselfwithresult7
)
接口使之终止时,只将正常结果返回给最后一个调用方, 其它调用方返回异常信息, 异常信息中resultCode为-1。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
...
...
@@ -469,7 +475,7 @@ getContext(): Context
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
()
let
context
=
featureAbility
.
getContext
()
context
.
getBundleName
((
err
,
data
)
=>
{
console
.
info
(
"
getBundleName err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -558,7 +564,7 @@ function onDisconnectCallback(element){
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connectId
=
featureAbility
.
connectAbility
(
let
connectId
=
featureAbility
.
connectAbility
(
{
deviceId
:
""
,
bundleName
:
"
com.ix.ServiceAbility
"
,
...
...
@@ -601,7 +607,7 @@ function onDisconnectCallback(element){
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connectId
=
featureAbility
.
connectAbility
(
let
connectId
=
featureAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
com.ix.ServiceAbility.ServiceAbilityA
"
,
...
...
@@ -653,7 +659,7 @@ function onDisconnectCallback(element){
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connectId
=
featureAbility
.
connectAbility
(
let
connectId
=
featureAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
com.ix.ServiceAbility.ServiceAbilityA
"
,
...
...
zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md
浏览文件 @
21529cb2
...
...
@@ -190,7 +190,7 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper
```
ts
import
particleAbility
from
'
@ohos.ability.particleAbility
'
var
uri
=
""
;
let
uri
=
""
;
particleAbility
.
acquireDataAbilityHelper
(
uri
)
```
...
...
@@ -416,7 +416,7 @@ function onFailedCallback(code) {
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
particleAbility
.
connectAbility
(
let
connId
=
particleAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
...
...
@@ -467,7 +467,7 @@ function onFailedCallback(code) {
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
particleAbility
.
connectAbility
(
let
connId
=
particleAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
...
...
@@ -518,7 +518,7 @@ function onFailedCallback(code) {
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
particleAbility
.
connectAbility
(
let
connId
=
particleAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
浏览文件 @
21529cb2
...
...
@@ -35,7 +35,7 @@ onConfigurationUpdated(config: Configuration): void;
```
ts
import
Ability
from
"
@ohos.application.Ability
"
;
var
callbackId
;
let
callbackId
;
export
default
class
MyAbility
extends
Ability
{
onCreate
()
{
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md
浏览文件 @
21529cb2
...
...
@@ -29,7 +29,7 @@ on(type: "error", observer: ErrorObserver): number;
**示例:**
```
js
var
observer
=
{
let
observer
=
{
onUnhandledException
(
errorMsg
)
{
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
)
}
...
...
@@ -60,7 +60,7 @@ off(type: "error", observerId: number, callback: AsyncCallback\<void>): void;
**示例:**
```
js
var
observerId
=
100
;
let
observerId
=
100
;
function
unregisterErrorObserverCallback
(
err
)
{
if
(
err
)
{
...
...
@@ -98,7 +98,7 @@ off(type: "error", observerId: number): Promise\<void>;
**示例:**
```
js
var
observerId
=
100
;
let
observerId
=
100
;
try
{
errorManager
.
off
(
"
error
"
,
observerId
)
.
then
((
data
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md
浏览文件 @
21529cb2
...
...
@@ -43,7 +43,7 @@ on(type:"mission", listener: MissionListener): number;
**示例:**
```
ts
var
listener
=
{
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
...
...
@@ -53,7 +53,7 @@ on(type:"mission", listener: MissionListener): number;
};
console
.
log
(
"
registerMissionListener
"
)
try
{
var
listenerid
=
missionManager
.
on
(
"
mission
"
,
listener
);
let
listenerid
=
missionManager
.
on
(
"
mission
"
,
listener
);
}
catch
(
paramError
)
{
console
.
log
(
"
error:
"
+
paramError
.
code
+
"
,
"
+
paramError
.
message
);
}
...
...
@@ -82,7 +82,7 @@ off(type: "mission", listenerId: number, callback: AsyncCallback<void>): v
**示例:**
```
ts
var
listener
=
{
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
...
...
@@ -92,7 +92,7 @@ off(type: "mission", listenerId: number, callback: AsyncCallback<void>): v
};
console
.
log
(
"
registerMissionListener
"
)
try
{
var
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
missionManager
.
unregisterMissionListener
(
listenerid
,
(
error
)
=>
{
console
.
log
(
"
unregisterMissionListener
"
);
...
...
@@ -130,7 +130,7 @@ off(type: "mission", listenerId: number): Promise<void>;
**示例:**
```
ts
var
listener
=
{
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
...
...
@@ -140,7 +140,7 @@ off(type: "mission", listenerId: number): Promise<void>;
};
console
.
log
(
"
registerMissionListener
"
)
try
{
var
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
missionManager
.
unregisterMissionListener
(
listenerid
).
catch
(
function
(
err
)
{
console
.
log
(
err
);
...
...
@@ -177,7 +177,7 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
var
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
let
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
""
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
console
.
log
(
"
getMissionInfo is called, error.code =
"
+
error
.
code
)
console
.
log
(
"
mission.missionId =
"
+
mission
.
missionId
);
...
...
@@ -224,7 +224,7 @@ getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
var
mission
=
missionManager
.
getMissionInfo
(
""
,
10
).
catch
(
function
(
err
){
let
mission
=
missionManager
.
getMissionInfo
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
...
...
@@ -301,7 +301,7 @@ getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionIn
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
var
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
let
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
...
...
@@ -340,7 +340,7 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
...
...
@@ -384,15 +384,15 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
var
snapshot
=
missionManager
.
getMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
let
snapshot
=
missionManager
.
getMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
...
...
@@ -430,7 +430,7 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getLowResolutionMissionSnapShot is called, error.code =
"
+
error
.
code
);
...
...
@@ -474,15 +474,15 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<M
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
var
snapshot
=
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
let
snapshot
=
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
}
catch
(
paramError
)
{
...
...
@@ -520,7 +520,7 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void;
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
lockMission is called
"
);
...
...
@@ -562,13 +562,13 @@ lockMission(missionId: number): Promise<void>;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
...
...
@@ -608,7 +608,7 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void;
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
unlockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
unlockMission is called
"
);
...
...
@@ -650,13 +650,13 @@ unlockMission(missionId: number): Promise<void>;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
...
...
@@ -699,7 +699,7 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void;
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
clearMission
(
id
).
then
(()
=>
{
console
.
log
(
"
clearMission is called
"
);
...
...
@@ -741,13 +741,13 @@ clearMission(missionId: number): Promise<void>;
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
clearMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
...
...
@@ -838,7 +838,7 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
...
...
@@ -880,7 +880,7 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
,{
windowMode
:
101
}).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
...
...
@@ -923,13 +923,13 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise<void&g
import
missionManager
from
'
@ohos.app.ability.missionManager
'
try
{
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
...
...
zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
浏览文件 @
21529cb2
...
...
@@ -361,8 +361,8 @@ call(method: string, data: rpc.Sequenceable): Promise<void>;
return
true
;
}
};
var
method
=
'
call_Function
'
;
// 约定的通知消息字符串
var
caller
;
let
method
=
'
call_Function
'
;
// 约定的通知消息字符串
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -442,8 +442,8 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
return
true
;
}
};
var
method
=
'
call_Function
'
;
var
caller
;
let
method
=
'
call_Function
'
;
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -493,7 +493,7 @@ release(): void;
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
var
caller
;
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -534,7 +534,7 @@ release(): void;
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
var
caller
;
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -585,7 +585,7 @@ release(): void;
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
var
caller
;
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -635,7 +635,7 @@ off(type: "release", callback: OnReleaseCallback): void;
**示例:**
```
ts
var
caller
;
let
caller
;
export
default
class
MainUIAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -686,7 +686,7 @@ off(type: "release"): void;
**示例:**
```
ts
var
caller
;
let
caller
;
export
default
class
MainUIAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -764,7 +764,7 @@ on(method: string, callback: CalleeCallback): void;
return
true
;
}
};
var
method
=
'
call_Function
'
;
let
method
=
'
call_Function
'
;
function
funcCallBack
(
pdata
)
{
console
.
log
(
'
Callee funcCallBack is called
'
+
pdata
);
let
msg
=
new
MyMessageAble
(
"
test
"
,
""
);
...
...
@@ -810,7 +810,7 @@ off(method: string): void;
```
ts
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
var
method
=
'
call_Function
'
;
let
method
=
'
call_Function
'
;
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
Callee onCreate is called
'
);
...
...
zh-cn/application-dev/reference/apis/js-apis-application-ability.md
浏览文件 @
21529cb2
...
...
@@ -326,7 +326,7 @@ onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any})
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| reason |
[
AbilityConstant.StateType
](
js-apis-app
lication
-abilityConstant.md#abilityconstantstatetype
)
| 是 | 回调保存状态的原因。 |
| reason |
[
AbilityConstant.StateType
](
js-apis-app
-ability
-abilityConstant.md#abilityconstantstatetype
)
| 是 | 回调保存状态的原因。 |
| wantParam | {[key:
string]:
any} | 是 | want相关参数。 |
**返回值:**
...
...
@@ -411,8 +411,8 @@ call(method: string, data: rpc.Sequenceable): Promise<void>;
return
true
;
}
};
var
method
=
'
call_Function
'
;
// 约定的通知消息字符串
var
caller
;
let
method
=
'
call_Function
'
;
// 约定的通知消息字符串
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -495,8 +495,8 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
return
true
;
}
};
var
method
=
'
call_Function
'
;
var
caller
;
let
method
=
'
call_Function
'
;
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -546,7 +546,7 @@ release(): void;
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
var
caller
;
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -587,7 +587,7 @@ release(): void;
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
var
caller
;
let
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
...
...
@@ -665,7 +665,7 @@ on(method: string, callback: CalleeCallBack): void;
return
true
;
}
};
var
method
=
'
call_Function
'
;
let
method
=
'
call_Function
'
;
function
funcCallBack
(
pdata
)
{
console
.
log
(
'
Callee funcCallBack is called
'
+
pdata
);
let
msg
=
new
MyMessageAble
(
"
test
"
,
""
);
...
...
@@ -712,7 +712,7 @@ off(method: string): void;
```
ts
import
Ability
from
'
@ohos.application.Ability
'
;
var
method
=
'
call_Function
'
;
let
method
=
'
call_Function
'
;
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
Callee onCreate is called
'
);
...
...
zh-cn/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
浏览文件 @
21529cb2
...
...
@@ -43,7 +43,7 @@ getAbilityDelegator(): AbilityDelegator
**示例:**
```
ts
var
abilityDelegator
;
let
abilityDelegator
;
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
```
...
...
@@ -65,7 +65,7 @@ getArguments(): AbilityDelegatorArgs
**示例:**
```
ts
var
args
=
AbilityDelegatorRegistry
.
getArguments
();
let
args
=
AbilityDelegatorRegistry
.
getArguments
();
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
浏览文件 @
21529cb2
...
...
@@ -159,7 +159,7 @@ onAbilityContinue(ability: Ability): void;
```
ts
import
AbilityStage
from
"
@ohos.application.AbilityStage
"
;
var
lifecycleid
;
let
lifecycleid
;
export
default
class
MyAbilityStage
extends
AbilityStage
{
onCreate
()
{
...
...
@@ -210,4 +210,5 @@ export default class MyAbilityStage extends AbilityStage {
});
}
}
```
\ No newline at end of file
```
<!--no_check-->
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-application-abilityManager.md
浏览文件 @
21529cb2
...
...
@@ -51,7 +51,7 @@ updateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void
```
ts
import
abilitymanager
from
'
@ohos.application.abilityManager
'
;
var
config
=
{
let
config
=
{
language
:
'
chinese
'
}
...
...
@@ -87,7 +87,7 @@ updateConfiguration(config: Configuration): Promise\<void>
```
ts
import
abilitymanager
from
'
@ohos.application.abilityManager
'
;
var
config
=
{
let
config
=
{
language
:
'
chinese
'
}
...
...
zh-cn/application-dev/reference/apis/js-apis-application-appManager.md
浏览文件 @
21529cb2
...
...
@@ -282,7 +282,7 @@ registerApplicationStateObserver(observer: ApplicationStateObserver): number;
**示例:**
```
ts
var
applicationStateObserver
=
{
let
applicationStateObserver
=
{
onForegroundApplicationChanged
(
appStateData
)
{
console
.
log
(
'
------------ onForegroundApplicationChanged -----------
'
,
appStateData
);
},
...
...
@@ -325,7 +325,7 @@ registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameL
**示例:**
```
ts
var
applicationStateObserver
=
{
let
applicationStateObserver
=
{
onForegroundApplicationChanged
(
appStateData
)
{
console
.
log
(
'
------------ onForegroundApplicationChanged -----------
'
,
appStateData
);
},
...
...
@@ -342,7 +342,7 @@ registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameL
console
.
log
(
'
------------ onProcessStateChanged -----------
'
,
processData
);
}
}
var
bundleNameList
=
[
'
bundleName1
'
,
'
bundleName2
'
];
let
bundleNameList
=
[
'
bundleName1
'
,
'
bundleName2
'
];
const
observerCode
=
app
.
registerApplicationStateObserver
(
applicationStateObserver
,
bundleNameList
);
console
.
log
(
'
-------- observerCode: ---------
'
,
observerCode
);
```
...
...
@@ -368,7 +368,7 @@ unregisterApplicationStateObserver(observerId: number, callback: AsyncCallback\
**示例:**
```
ts
var
observerId
=
100
;
let
observerId
=
100
;
function
unregisterApplicationStateObserverCallback
(
err
)
{
if
(
err
)
{
...
...
@@ -405,7 +405,7 @@ unregisterApplicationStateObserver(observerId: number): Promise\<void>;
**示例:**
```
ts
var
observerId
=
100
;
let
observerId
=
100
;
app
.
unregisterApplicationStateObserver
(
observerId
)
.
then
((
data
)
=>
{
...
...
@@ -499,8 +499,8 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\>
**示例:**
```
ts
var
bundleName
=
'
bundleName
'
;
var
accountId
=
0
;
let
bundleName
=
'
bundleName
'
;
let
accountId
=
0
;
app
.
killProcessWithAccount
(
bundleName
,
accountId
)
.
then
((
data
)
=>
{
console
.
log
(
'
------------ killProcessWithAccount success ------------
'
,
data
);
...
...
@@ -534,8 +534,8 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal
**示例:**
```
ts
var
bundleName
=
'
bundleName
'
;
var
accountId
=
0
;
let
bundleName
=
'
bundleName
'
;
let
accountId
=
0
;
function
killProcessWithAccountCallback
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
'
------------- killProcessWithAccountCallback fail, err: --------------
'
,
err
);
...
...
@@ -568,7 +568,7 @@ killProcessesByBundleName(bundleName: string, callback: AsyncCallback\<void>);
**示例:**
```
ts
var
bundleName
=
'
bundleName
'
;
let
bundleName
=
'
bundleName
'
;
function
killProcessesByBundleNameCallback
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
'
------------- killProcessesByBundleNameCallback fail, err: --------------
'
,
err
);
...
...
@@ -606,7 +606,7 @@ killProcessesByBundleName(bundleName: string): Promise\<void>;
**示例:**
```
ts
var
bundleName
=
'
bundleName
'
;
let
bundleName
=
'
bundleName
'
;
app
.
killProcessesByBundleName
(
bundleName
)
.
then
((
data
)
=>
{
console
.
log
(
'
------------ killProcessesByBundleName success ------------
'
,
data
);
...
...
@@ -638,7 +638,7 @@ clearUpApplicationData(bundleName: string, callback: AsyncCallback\<void>);
**示例:**
```
ts
var
bundleName
=
'
bundleName
'
;
let
bundleName
=
'
bundleName
'
;
function
clearUpApplicationDataCallback
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
'
------------- clearUpApplicationDataCallback fail, err: --------------
'
,
err
);
...
...
@@ -676,7 +676,7 @@ clearUpApplicationData(bundleName: string): Promise\<void>;
**示例:**
```
ts
var
bundleName
=
'
bundleName
'
;
let
bundleName
=
'
bundleName
'
;
app
.
clearUpApplicationData
(
bundleName
)
.
then
((
data
)
=>
{
console
.
log
(
'
------------ clearUpApplicationData success ------------
'
,
data
);
...
...
zh-cn/application-dev/reference/apis/js-apis-application-environmentCallback.md
浏览文件 @
21529cb2
...
...
@@ -35,7 +35,7 @@ onConfigurationUpdated(config: Configuration): void;
```
ts
import
Ability
from
"
@ohos.application.Ability
"
;
var
callbackId
;
let
callbackId
;
export
default
class
MyAbility
extends
Ability
{
onCreate
()
{
...
...
zh-cn/application-dev/reference/apis/js-apis-application-errorManager.md
浏览文件 @
21529cb2
...
...
@@ -28,7 +28,7 @@ registerErrorObserver(observer: ErrorObserver): number;
**示例:**
```
ts
var
observer
=
{
let
observer
=
{
onUnhandledException
(
errorMsg
)
{
console
.
log
(
'
onUnhandledException, errorMsg:
'
,
errorMsg
)
}
...
...
@@ -54,7 +54,7 @@ unregisterErrorObserver(observerId: number, callback: AsyncCallback\<void>): vo
**示例:**
```
ts
var
observerId
=
100
;
let
observerId
=
100
;
function
unregisterErrorObserverCallback
(
err
)
{
if
(
err
)
{
...
...
@@ -88,7 +88,7 @@ unregisterErrorObserver(observerId: number): Promise\<void>;
**示例:**
```
ts
var
observerId
=
100
;
let
observerId
=
100
;
errorManager
.
unregisterErrorObserver
(
observerId
)
.
then
((
data
)
=>
{
console
.
log
(
'
----------- unregisterErrorObserver success ----------
'
,
data
);
...
...
zh-cn/application-dev/reference/apis/js-apis-application-missionManager.md
浏览文件 @
21529cb2
...
...
@@ -43,7 +43,7 @@ registerMissionListener(listener: MissionListener): number;
**示例:**
```
ts
var
listener
=
{
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
...
...
@@ -53,7 +53,7 @@ var listener = {
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)}
};
console
.
log
(
"
registerMissionListener
"
)
var
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
```
...
...
@@ -79,7 +79,7 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>
**示例:**
```
ts
var
listener
=
{
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
...
...
@@ -89,7 +89,7 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback<void>
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)}
};
console
.
log
(
"
registerMissionListener
"
)
var
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
missionManager
.
unregisterMissionListener
(
listenerid
,
(
error
)
=>
{
console
.
log
(
"
unregisterMissionListener
"
);
...
...
@@ -124,7 +124,7 @@ unregisterMissionListener(listenerId: number): Promise<void>;
**示例:**
```
ts
var
listener
=
{
let
listener
=
{
onMissionCreated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionCreated-------
"
)},
onMissionDestroyed
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionDestroyed-------
"
)},
onMissionSnapshotChanged
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionSnapshotChanged-------
"
)},
...
...
@@ -134,7 +134,7 @@ unregisterMissionListener(listenerId: number): Promise<void>;
onMissionLabelUpdated
:
function
(
mission
)
{
console
.
log
(
"
--------onMissionLabelUpdated-------
"
)}
};
console
.
log
(
"
registerMissionListener
"
)
var
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
let
listenerid
=
missionManager
.
registerMissionListener
(
listener
);
missionManager
.
unregisterMissionListener
(
listenerid
).
catch
(
function
(
err
)
{
console
.
log
(
err
);
...
...
@@ -167,7 +167,7 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<M
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
var
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
let
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);});
missionManager
.
getMissionInfo
(
""
,
allMissions
[
0
].
missionId
,
(
error
,
mission
)
=>
{
console
.
log
(
"
getMissionInfo is called, error.code =
"
+
error
.
code
)
console
.
log
(
"
mission.missionId =
"
+
mission
.
missionId
);
...
...
@@ -210,7 +210,7 @@ getMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo>;
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
var
mission
=
missionManager
.
getMissionInfo
(
""
,
10
).
catch
(
function
(
err
){
let
mission
=
missionManager
.
getMissionInfo
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
```
...
...
@@ -279,7 +279,7 @@ getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionIn
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
var
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
let
allMissions
=
missionManager
.
getMissionInfos
(
""
,
10
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
```
...
...
@@ -314,7 +314,7 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
...
...
@@ -354,15 +354,15 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnaps
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
var
snapshot
=
missionManager
.
getMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
let
snapshot
=
missionManager
.
getMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
```
...
...
@@ -396,7 +396,7 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getLowResolutionMissionSnapShot is called, error.code =
"
+
error
.
code
);
...
...
@@ -436,15 +436,15 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<M
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
var
snapshot
=
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
let
snapshot
=
missionManager
.
getLowResolutionMissionSnapShot
(
""
,
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
});
```
...
...
@@ -478,7 +478,7 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void;
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
lockMission is called
"
);
...
...
@@ -515,13 +515,13 @@ lockMission(missionId: number): Promise<void>;
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
...
...
@@ -557,7 +557,7 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void;
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
unlockMission
(
id
).
then
(()
=>
{
console
.
log
(
"
unlockMission is called
"
);
...
...
@@ -595,13 +595,13 @@ unlockMission(missionId: number): Promise<void>;
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
lockMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
...
...
@@ -640,7 +640,7 @@ clearMission(missionId: number, callback: AsyncCallback<void>): void;
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
clearMission
(
id
).
then
(()
=>
{
console
.
log
(
"
clearMission is called
"
);
...
...
@@ -678,13 +678,13 @@ clearMission(missionId: number): Promise<void>;
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
clearMission
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
...
...
@@ -771,7 +771,7 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
...
...
@@ -797,7 +797,7 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| missionId | number | 是 | 任务ID。 |
| options |
[
StartOptions
](
js-apis-app
lication
-startOptions.md
)
| 是 | 启动参数选项,用于指定任务切到前台时的窗口模式,设备ID等。 |
| options |
[
StartOptions
](
js-apis-app
-ability
-startOptions.md
)
| 是 | 启动参数选项,用于指定任务切到前台时的窗口模式,设备ID等。 |
| callback | AsyncCallback
<
void
>
| 是 | 执行结果回调函数。 |
**示例:**
...
...
@@ -809,7 +809,7 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
,{
windowMode
:
101
}).
then
(()
=>
{
console
.
log
(
"
moveMissionToFront is called
"
);
...
...
@@ -835,7 +835,7 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise<void&g
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| missionId | number | 是 | 任务ID。 |
| options |
[
StartOptions
](
js-apis-app
lication
-startOptions.md
)
| 否 | 启动参数选项,用于指定任务切到前台时的窗口模式,设备ID等。 |
| options |
[
StartOptions
](
js-apis-app
-ability
-startOptions.md
)
| 否 | 启动参数选项,用于指定任务切到前台时的窗口模式,设备ID等。 |
**返回值:**
...
...
@@ -848,13 +848,13 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise<void&g
```
ts
import
missionManager
from
'
@ohos.application.missionManager
'
var
allMissions
;
let
allMissions
;
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
));
var
id
=
allMissions
[
0
].
missionId
;
let
id
=
allMissions
[
0
].
missionId
;
missionManager
.
moveMissionToFront
(
id
).
catch
(
function
(
err
){
console
.
log
(
err
);
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md
浏览文件 @
21529cb2
...
...
@@ -35,10 +35,10 @@ openFile(uri: string, mode: string, callback: AsyncCallback\<number>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
mode
=
"
rwt
"
;
let
mode
=
"
rwt
"
;
DAHelper
.
openFile
(
"
dataability:///com.example.DataAbility
"
,
mode
,
(
err
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
...
...
@@ -69,10 +69,10 @@ openFile(uri: string, mode: string): Promise\<number>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
mode
=
"
rwt
"
;
let
mode
=
"
rwt
"
;
DAHelper
.
openFile
(
"
dataability:///com.example.DataAbility
"
,
mode
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>openFileCallback=======================>
"
);
});
...
...
@@ -98,7 +98,7 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback\<void>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
helper
=
featureAbility
.
acquireDataAbilityHelper
(
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
function
onChangeNotify
()
{
...
...
@@ -131,7 +131,7 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback\<void>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
helper
=
featureAbility
.
acquireDataAbilityHelper
(
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
function
onChangeNotify
()
{
...
...
@@ -167,7 +167,7 @@ getType(uri: string, callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
getType
(
"
dataability:///com.example.DataAbility
"
,
(
err
,
data
)
=>
{
...
...
@@ -199,7 +199,7 @@ getType(uri: string): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
getType
(
"
dataability:///com.example.DataAbility
"
).
then
((
data
)
=>
{
...
...
@@ -227,7 +227,7 @@ getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array\
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
getFileTypes
(
"
dataability:///com.example.DataAbility
"
,
...
...
@@ -263,7 +263,7 @@ getFileTypes(uri: string, mimeTypeFilter: string): Promise\<Array\<string>>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
getFileTypes
(
"
dataability:///com.example.DataAbility
"
,
...
...
@@ -291,7 +291,7 @@ normalizeUri(uri: string, callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
normalizeUri
(
"
dataability:///com.example.DataAbility
"
,
(
err
,
data
)
=>
{
...
...
@@ -323,7 +323,7 @@ normalizeUri(uri: string): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
normalizeUri
(
"
dataability:///com.example.DataAbility
"
,).
then
((
data
)
=>
{
...
...
@@ -350,7 +350,7 @@ denormalizeUri(uri: string, callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
denormalizeUri
(
"
dataability:///com.example.DataAbility
"
,
(
err
,
data
)
=>
{
...
...
@@ -384,7 +384,7 @@ denormalizeUri(uri: string): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
denormalizeUri
(
"
dataability:///com.example.DataAbility
"
,).
then
((
data
)
=>
{
...
...
@@ -411,7 +411,7 @@ notifyChange(uri: string, callback: AsyncCallback\<void>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
helper
=
featureAbility
.
acquireDataAbilityHelper
(
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
helper
.
notifyChange
(
"
dataability:///com.example.DataAbility
"
,
(
err
)
=>
{
...
...
@@ -443,7 +443,7 @@ notifyChange(uri: string): Promise\<void>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
notifyChange
(
"
dataability:///com.example.DataAbility
"
).
then
(()
=>
{
...
...
@@ -471,7 +471,7 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\<num
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
const
valueBucket
=
{
...
...
@@ -511,7 +511,7 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket): Promise\<number>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
const
valueBucket
=
{
...
...
@@ -545,10 +545,10 @@ batchInsert(uri: string, valuesBuckets: Array\<rdb.ValuesBucket>, callback: Asyn
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
cars
=
new
Array
({
"
name
"
:
"
roe11
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,},
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
,
...
...
@@ -582,10 +582,10 @@ batchInsert(uri: string, valuesBuckets: Array<rdb.ValuesBucket>): Promise\<numbe
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
cars
=
new
Array
({
"
name
"
:
"
roe11
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
"
u8
"
,},
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
)
=>
{
...
...
@@ -614,7 +614,7 @@ delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: Asy
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
...
...
@@ -650,7 +650,7 @@ delete(uri: string, predicates?: dataAbility.DataAbilityPredicates): Promise\<nu
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
...
...
@@ -681,7 +681,7 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.Data
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
const
va
=
{
...
...
@@ -723,7 +723,7 @@ update(uri: string, valuesBucket: rdb.ValuesBucket, predicates?: dataAbility.Dat
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
const
va
=
{
...
...
@@ -760,10 +760,10 @@ query(uri: string, columns: Array\<string>, predicates: dataAbility.DataAbilityP
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
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
(
"
==========================>Called=======================>
"
);
...
...
@@ -799,10 +799,10 @@ query(uri: string, columns?: Array\<string>, predicates?: dataAbility.DataAbilit
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataAbility
'
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
let
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
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
(
"
==========================>queryCallback=======================>
"
);
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-app-context.md
浏览文件 @
21529cb2
...
...
@@ -13,7 +13,7 @@ Context对象是在featureAbility中创建实例,并通过featureAbility的[ge
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
().
then
((
data
)
=>
{
console
.
info
(
"
getOrCreateLocalDir data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -39,7 +39,7 @@ getOrCreateLocalDir(callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
((
err
,
data
)
=>
{
console
.
info
(
"
getOrCreateLocalDir err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -67,7 +67,7 @@ getOrCreateLocalDir(): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
().
then
((
data
)
=>
{
console
.
info
(
"
getOrCreateLocalDir data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -94,7 +94,7 @@ verifyPermission(permission: string, options: PermissionOptions, callback: Async
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
bundle
from
'
@ohos.bundle
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
bundle
.
getBundleInfo
(
'
com.context.test
'
,
1
,
(
err
,
datainfo
)
=>
{
context
.
verifyPermission
(
"
com.example.permission
"
,
{
uid
:
datainfo
.
uid
},
(
err
,
data
)
=>
{
console
.
info
(
"
verifyPermission err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
...
...
@@ -123,7 +123,7 @@ verifyPermission(permission: string, callback: AsyncCallback\<number>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
verifyPermission
(
"
com.example.permission
"
,
(
err
,
data
)
=>
{
console
.
info
(
"
verifyPermission err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -154,8 +154,8 @@ verifyPermission(permission: string, options?: PermissionOptions): Promise\<numb
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
var
Permission
=
{
pid
:
1
};
let
context
=
featureAbility
.
getContext
();
let
Permission
=
{
pid
:
1
};
context
.
verifyPermission
(
'
com.context.permission
'
,
Permission
).
then
((
data
)
=>
{
console
.
info
(
"
verifyPermission data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -183,7 +183,7 @@ requestPermissionsFromUser(permissions: Array\<string>, requestCode: number, res
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
requestPermissionsFromUser
(
[
"
com.example.permission1
"
,
"
com.example.permission2
"
,
...
...
@@ -223,7 +223,7 @@ requestPermissionsFromUser(permissions: Array\<string>, requestCode: number): Pr
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
requestPermissionsFromUser
(
[
"
com.example.permission1
"
,
"
com.example.permission2
"
,
...
...
@@ -256,7 +256,7 @@ getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getApplicationInfo
((
err
,
data
)
=>
{
console
.
info
(
"
getApplicationInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -282,7 +282,7 @@ getApplicationInfo(): Promise\<ApplicationInfo>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getApplicationInfo
().
then
((
data
)
=>
{
console
.
info
(
"
getApplicationInfo data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -308,7 +308,7 @@ getBundleName(callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getBundleName
((
err
,
data
)
=>
{
console
.
info
(
"
getBundleName err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -334,7 +334,7 @@ getBundleName(): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getBundleName
().
then
((
data
)
=>
{
console
.
info
(
"
getBundleName data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -358,7 +358,7 @@ getDisplayOrientation(callback: AsyncCallback\<bundle.DisplayOrientation>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getDisplayOrientation
((
err
,
data
)
=>
{
console
.
info
(
"
getDisplayOrientation err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -382,7 +382,7 @@ getDisplayOrientation(): Promise\<bundle.DisplayOrientation>;
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getDisplayOrientation
().
then
((
data
)
=>
{
console
.
info
(
"
getDisplayOrientation data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -406,7 +406,7 @@ getExternalCacheDir(callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getExternalCacheDir
((
err
,
data
)
=>
{
console
.
info
(
"
getExternalCacheDir err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -430,7 +430,7 @@ getExternalCacheDir(): Promise\<string>;
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getExternalCacheDir
().
then
((
data
)
=>
{
console
.
info
(
"
getExternalCacheDir data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -456,8 +456,8 @@ setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCal
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
bundle
from
'
@ohos.bundle
'
;
var
context
=
featureAbility
.
getContext
();
var
orientation
=
bundle
.
DisplayOrientation
.
UNSPECIFIED
let
context
=
featureAbility
.
getContext
();
let
orientation
=
bundle
.
DisplayOrientation
.
UNSPECIFIED
context
.
setDisplayOrientation
(
orientation
,
(
err
)
=>
{
console
.
info
(
"
setDisplayOrientation err:
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -483,8 +483,8 @@ setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise\<void>;
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
bundle
from
'
@ohos.bundle
'
;
var
context
=
featureAbility
.
getContext
();
var
orientation
=
bundle
.
DisplayOrientation
.
UNSPECIFIED
let
context
=
featureAbility
.
getContext
();
let
orientation
=
bundle
.
DisplayOrientation
.
UNSPECIFIED
context
.
setDisplayOrientation
(
orientation
).
then
((
data
)
=>
{
console
.
info
(
"
setDisplayOrientation data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -509,8 +509,8 @@ setShowOnLockScreen(show: boolean, callback: AsyncCallback\<void>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
var
show
=
true
let
context
=
featureAbility
.
getContext
();
let
show
=
true
context
.
setShowOnLockScreen
(
show
,
(
err
)
=>
{
console
.
info
(
"
setShowOnLockScreen err:
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -540,8 +540,8 @@ setShowOnLockScreen(show: boolean): Promise\<void>;
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
var
show
=
true
let
context
=
featureAbility
.
getContext
();
let
show
=
true
context
.
setShowOnLockScreen
(
show
).
then
((
data
)
=>
{
console
.
info
(
"
setShowOnLockScreen data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -566,8 +566,8 @@ setWakeUpScreen(wakeUp: boolean, callback: AsyncCallback\<void>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
var
wakeUp
=
true
let
context
=
featureAbility
.
getContext
();
let
wakeUp
=
true
context
.
setWakeUpScreen
(
wakeUp
,
(
err
)
=>
{
console
.
info
(
"
setWakeUpScreen err:
"
+
JSON
.
stringify
(
err
));
});
...
...
@@ -597,8 +597,8 @@ setWakeUpScreen(wakeUp: boolean): Promise\<void>;
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
var
wakeUp
=
true
let
context
=
featureAbility
.
getContext
();
let
wakeUp
=
true
context
.
setWakeUpScreen
(
wakeUp
).
then
((
data
)
=>
{
console
.
info
(
"
setWakeUpScreen data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -625,7 +625,7 @@ getProcessInfo(callback: AsyncCallback\<ProcessInfo>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getProcessInfo
((
err
,
data
)
=>
{
console
.
info
(
"
getProcessInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -651,7 +651,7 @@ getProcessInfo(): Promise\<ProcessInfo>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getProcessInfo
().
then
((
data
)
=>
{
console
.
info
(
"
getProcessInfo data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -679,7 +679,7 @@ getElementName(callback: AsyncCallback\<ElementName>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getElementName
((
err
,
data
)
=>
{
console
.
info
(
"
getElementName err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -707,7 +707,7 @@ getElementName(): Promise\<ElementName>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getElementName
().
then
((
data
)
=>
{
console
.
info
(
"
getElementName data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -731,7 +731,7 @@ getProcessName(callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getProcessName
((
err
,
data
)
=>
{
console
.
info
(
"
getProcessName err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -757,7 +757,7 @@ getProcessName(): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getProcessName
().
then
((
data
)
=>
{
console
.
info
(
"
getProcessName data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -783,7 +783,7 @@ getCallingBundle(callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getCallingBundle
((
err
,
data
)
=>
{
console
.
info
(
"
getCallingBundle err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -809,7 +809,7 @@ getCallingBundle(): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getCallingBundle
().
then
((
data
)
=>
{
console
.
info
(
"
getCallingBundle data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -833,7 +833,7 @@ getCacheDir(callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getCacheDir
((
err
,
data
)
=>
{
console
.
info
(
"
getCacheDir err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -857,7 +857,7 @@ getCacheDir(): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getCacheDir
().
then
((
data
)
=>
{
console
.
info
(
"
getCacheDir data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -881,7 +881,7 @@ getFilesDir(callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getFilesDir
((
err
,
data
)
=>
{
console
.
info
(
"
getFilesDir err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -905,7 +905,7 @@ getFilesDir(): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getFilesDir
().
then
((
data
)
=>
{
console
.
info
(
"
getFilesDir data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -931,7 +931,7 @@ getOrCreateDistributedDir(callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateDistributedDir
((
err
,
data
)
=>
{
console
.
info
(
"
getOrCreateDistributedDir err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -957,7 +957,7 @@ getOrCreateDistributedDir(): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateDistributedDir
().
then
((
data
)
=>
{
console
.
info
(
"
getOrCreateDistributedDir data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -981,7 +981,7 @@ getAppType(callback: AsyncCallback\<string>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getAppType
((
err
,
data
)
=>
{
console
.
info
(
"
getAppType err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1005,7 +1005,7 @@ getAppType(): Promise\<string>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getAppType
().
then
((
data
)
=>
{
console
.
info
(
"
getAppType data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1029,7 +1029,7 @@ getHapModuleInfo(callback: AsyncCallback\<HapModuleInfo>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getHapModuleInfo
((
err
,
data
)
=>
{
console
.
info
(
"
getHapModuleInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1053,7 +1053,7 @@ getHapModuleInfo(): Promise\<HapModuleInfo>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getHapModuleInfo
().
then
((
data
)
=>
{
console
.
info
(
"
getHapModuleInfo data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1077,7 +1077,7 @@ getAppVersionInfo(callback: AsyncCallback\<AppVersionInfo>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getAppVersionInfo
((
err
,
data
)
=>
{
console
.
info
(
"
getAppVersionInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1101,7 +1101,7 @@ getAppVersionInfo(): Promise\<AppVersionInfo>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getAppVersionInfo
().
then
((
data
)
=>
{
console
.
info
(
"
getAppVersionInfo data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1125,7 +1125,7 @@ getAbilityInfo(callback: AsyncCallback\<AbilityInfo>): void
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getAbilityInfo
((
err
,
data
)
=>
{
console
.
info
(
"
getAbilityInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1149,7 +1149,7 @@ getAbilityInfo(): Promise\<AbilityInfo>
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getAbilityInfo
().
then
((
data
)
=>
{
console
.
info
(
"
getAbilityInfo data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1173,7 +1173,7 @@ getApplicationContext(): Context
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
().
getApplicationContext
();
let
context
=
featureAbility
.
getContext
().
getApplicationContext
();
```
## Context.isUpdatingConfigurations<sup>7+</sup>
...
...
@@ -1194,7 +1194,7 @@ isUpdatingConfigurations(callback: AsyncCallback\<boolean>): void;
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
isUpdatingConfigurations
((
err
,
data
)
=>
{
console
.
info
(
"
isUpdatingConfigurations err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1218,7 +1218,7 @@ isUpdatingConfigurations(): Promise\<boolean>;
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
isUpdatingConfigurations
().
then
((
data
)
=>
{
console
.
info
(
"
isUpdatingConfigurations data:
"
+
JSON
.
stringify
(
data
));
});
...
...
@@ -1242,7 +1242,7 @@ printDrawnCompleted(callback: AsyncCallback\<void>): void;
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
printDrawnCompleted
((
err
)
=>
{
console
.
error
(
'
printDrawnCompleted err:
'
+
JSON
.
stringify
(
err
));
});
...
...
@@ -1266,7 +1266,7 @@ printDrawnCompleted(): Promise\<void>;
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
printDrawnCompleted
().
then
((
data
)
=>
{
console
.
info
(
"
printDrawnCompleted data:
"
+
JSON
.
stringify
(
data
));
});
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-app-processInfo.md
浏览文件 @
21529cb2
...
...
@@ -17,7 +17,7 @@
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
();
let
context
=
featureAbility
.
getContext
();
context
.
getProcessInfo
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
info
(
"
getProcessInfo err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegatorArgs.md
浏览文件 @
21529cb2
...
...
@@ -28,5 +28,5 @@ AbilityDelegatorArgs模块提供在应用程序启动期间,用于存储已注
```
ts
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
;
var
args
=
AbilityDelegatorRegistry
.
getArguments
();
let
args
=
AbilityDelegatorRegistry
.
getArguments
();
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md
浏览文件 @
21529cb2
...
...
@@ -36,12 +36,12 @@ function onAbilityCreateCallback(data) {
console
.
info
(
"
onAbilityCreateCallback
"
);
}
var
monitor
=
{
let
monitor
=
{
abilityName
:
"
abilityname
"
,
onAbilityCreate
:
onAbilityCreateCallback
}
var
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
let
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
abilityDelegator
.
addAbilityMonitor
(
monitor
,
(
err
:
any
)
=>
{
console
.
info
(
"
addAbilityMonitor callback
"
);
});
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md
浏览文件 @
21529cb2
...
...
@@ -41,7 +41,7 @@ on(type: "abilityLifecycle", callback: AbilityLifecycleCallback): **number**;
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
var
lifecycleId
;
let
lifecycleId
;
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
()
{
...
...
@@ -109,7 +109,7 @@ off(type: "abilityLifecycle", callbackId: **number**, callback: AsyncCallback<*
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
var
lifecycleId
;
let
lifecycleId
;
export
default
class
EntryAbility
extends
UIAbility
{
onDestroy
()
{
...
...
@@ -142,7 +142,7 @@ off(type: "abilityLifecycle", callbackId: **number**): **void**;
```
ts
import
Ability
from
"
@ohos.app.ability.UIAbility
"
;
var
lifecycleId
;
let
lifecycleId
;
export
default
class
MyAbility
extends
Ability
{
onDestroy
()
{
...
...
@@ -179,7 +179,7 @@ on(type: "environment", callback: EnvironmentCallback): **number**;
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
var
callbackId
;
let
callbackId
;
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
()
{
...
...
@@ -223,7 +223,7 @@ off(type: "environment", callbackId: **number**, callback: AsyncCallback<**void
```
ts
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
var
callbackId
;
let
callbackId
;
export
default
class
EntryAbility
extends
UIAbility
{
onDestroy
()
{
...
...
@@ -255,7 +255,7 @@ off(type: "environment", callbackId: **number**, callback: AsyncCallback<**void
```
ts
import
Ability
from
"
@ohos.app.ability.UIAbility
"
;
var
callbackId
;
let
callbackId
;
export
default
class
MyAbility
extends
Ability
{
onDestroy
()
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-extensionContext.md
浏览文件 @
21529cb2
...
...
@@ -88,7 +88,7 @@ export default class ServiceModel {
return
;
}
var
moduleInfo
=
globalThis
.
ExtensionContext
.
currentHapModuleInfo
;
let
moduleInfo
=
globalThis
.
ExtensionContext
.
currentHapModuleInfo
;
this
.
moduleName
=
moduleInfo
.
name
;
// 根据moduleName执行不同的业务逻辑,实现对不同性能设备的区分
switch
(
this
.
moduleName
)
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md
浏览文件 @
21529cb2
...
...
@@ -28,7 +28,7 @@ missionManager.getMissionInfos("", 10, (error, missions) => {
console
.
log
(
"
getMissionInfos is called, error.code =
"
+
error
.
code
);
console
.
log
(
"
size =
"
+
missions
.
length
);
console
.
log
(
"
missions =
"
+
JSON
.
stringify
(
missions
));
var
id
=
missions
[
0
].
missionId
;
let
id
=
missions
[
0
].
missionId
;
missionManager
.
getMissionSnapShot
(
""
,
id
,
(
error
,
snapshot
)
=>
{
console
.
log
(
"
getMissionSnapShot is called, error.code =
"
+
error
.
code
);
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md
浏览文件 @
21529cb2
...
...
@@ -68,7 +68,7 @@ startAbility(want: Want, callback: AsyncCallback<void>): void;
**示例:**
```
ts
var
want
=
{
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
};
...
...
@@ -141,11 +141,11 @@ startAbility(want: Want, options?: StartOptions): Promise\<void>;
**示例:**
```
ts
var
want
=
{
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
};
var
options
=
{
let
options
=
{
windowMode
:
0
,
};
...
...
@@ -212,12 +212,12 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
options
=
{
let
options
=
{
windowMode
:
0
};
...
...
@@ -290,12 +290,12 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
startAbilityWithAccount
(
want
,
accountId
,
(
error
)
=>
{
...
...
@@ -367,13 +367,13 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
var
options
=
{
let
accountId
=
100
;
let
options
=
{
windowMode
:
0
};
...
...
@@ -453,13 +453,13 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions):
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
var
options
=
{
let
accountId
=
100
;
let
options
=
{
windowMode
:
0
};
...
...
@@ -518,7 +518,7 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
...
...
@@ -584,7 +584,7 @@ startServiceExtensionAbility(want: Want): Promise\<void>;
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
...
...
@@ -650,12 +650,12 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
startServiceExtensionAbilityWithAccount
(
want
,
accountId
,
(
error
)
=>
{
...
...
@@ -721,12 +721,12 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
startServiceExtensionAbilityWithAccount
(
want
,
accountId
)
...
...
@@ -780,7 +780,7 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
...
...
@@ -843,7 +843,7 @@ stopServiceExtensionAbility(want: Want): Promise\<void>;
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
...
...
@@ -905,12 +905,12 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback:
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
stopServiceExtensionAbilityWithAccount
(
want
,
accountId
,
(
error
)
=>
{
...
...
@@ -973,12 +973,12 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
let
accountId
=
100
;
try
{
this
.
context
.
stopServiceExtensionAbilityWithAccount
(
want
,
accountId
)
...
...
@@ -1118,17 +1118,17 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
**示例:**
```
ts
var
want
=
{
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
};
var
options
=
{
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
)
},
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
}
}
var
connection
=
null
;
let
connection
=
null
;
try
{
connection
=
this
.
context
.
connectServiceExtensionAbility
(
want
,
options
);
}
catch
(
paramError
)
{
...
...
@@ -1178,19 +1178,19 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
**示例:**
```
ts
var
want
=
{
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.extreme.test
"
,
abilityName
:
"
MainAbility
"
};
var
accountId
=
100
;
var
options
=
{
let
accountId
=
100
;
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
)
},
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
)
}
}
var
connection
=
null
;
let
connection
=
null
;
try
{
connection
=
this
.
context
.
connectServiceExtensionAbilityWithAccount
(
want
,
accountId
,
options
);
}
catch
(
paramError
)
{
...
...
@@ -1232,7 +1232,7 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback<
```
ts
// connection为connectServiceExtensionAbility中的返回值
var
connection
=
1
;
let
connection
=
1
;
try
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
,
(
error
)
=>
{
...
...
@@ -1289,7 +1289,7 @@ disconnectServiceExtensionAbility(connection: number): Promise<void>;
```
ts
// connection为connectServiceExtensionAbility中的返回值
var
connection
=
1
;
let
connection
=
1
;
try
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
)
...
...
@@ -1355,10 +1355,10 @@ startAbilityByCall(want: Want): Promise<Caller>;
后台启动:
```
ts
var
caller
=
undefined
;
let
caller
=
undefined
;
// 后台启动Ability,不配置parameters
var
wantBackground
=
{
let
wantBackground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
MainAbility
"
,
...
...
@@ -1386,10 +1386,10 @@ startAbilityByCall(want: Want): Promise<Caller>;
前台启动:
```
ts
var
caller
=
undefined
;
let
caller
=
undefined
;
// 前台启动Ability,将parameters中的"ohos.aafwk.param.callAbilityToForeground"配置为true
var
wantForeground
=
{
let
wantForeground
=
{
bundleName
:
"
com.example.myservice
"
,
moduleName
:
"
entry
"
,
abilityName
:
"
MainAbility
"
,
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
浏览文件 @
21529cb2
...
...
@@ -249,7 +249,10 @@ startAbility(want: Want, options?: StartOptions): Promise<void>;
startAbilityForResult(want: Want, callback: AsyncCallback
<
AbilityResult
>
): void;
启动一个Ability。Ability被启动后,正常情况下可通过调用
[
terminateSelfWithResult
](
#uiabilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用者。异常情况下比如杀死Ability会返回异常信息给调用者(callback形式)。
启动一个Ability。Ability被启动后,有如下情况(callback形式):
-
正常情况下可通过调用
[
terminateSelfWithResult
](
#uiabilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用方。
-
异常情况下比如杀死Ability会返回异常信息给调用方, 异常信息中resultCode为-1。
-
如果被启动的Ability模式是单实例模式, 不同应用多次调用该接口启动这个Ability,当这个Ability调用
[
terminateSelfWithResult
](
#uiabilitycontextterminateselfwithresult
)
接口使之终止时,只将正常结果返回给最后一个调用方, 其它调用方返回异常信息, 异常信息中resultCode为-1。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
...
...
@@ -321,7 +324,10 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>):
startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
<
AbilityResult
>
): void;
启动一个Ability。Ability被启动后,正常情况下可通过调用
[
terminateSelfWithResult
](
#uiabilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用者。异常情况下比如杀死Ability会返回异常信息给调用者(callback形式)。
启动一个Ability。Ability被启动后,有如下情况(callback形式):
-
正常情况下可通过调用
[
terminateSelfWithResult
](
#uiabilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用方。
-
异常情况下比如杀死Ability会返回异常信息给调用方, 异常信息中resultCode为-1。
-
如果被启动的Ability模式是单实例模式, 不同应用多次调用该接口启动这个Ability,当这个Ability调用
[
terminateSelfWithResult
](
#uiabilitycontextterminateselfwithresult
)
接口使之终止时,只将正常结果返回给最后一个调用方, 其它调用方返回异常信息, 异常信息中resultCode为-1。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
...
...
@@ -398,7 +404,10 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
startAbilityForResult(want: Want, options?: StartOptions): Promise
<
AbilityResult
>
;
启动一个Ability。Ability被启动后,正常情况下可通过调用
[
terminateSelfWithResult
](
#uiabilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用者。异常情况下比如杀死Ability会返回异常信息给调用者(promise形式)。
启动一个Ability。Ability被启动后,有如下情况(promise形式):
-
正常情况下可通过调用
[
terminateSelfWithResult
](
#uiabilitycontextterminateselfwithresult
)
接口使之终止并且返回结果给调用方。
-
异常情况下比如杀死Ability会返回异常信息给调用方, 异常信息中resultCode为-1。
-
如果被启动的Ability模式是单实例模式, 不同应用多次调用该接口启动这个Ability,当这个Ability调用
[
terminateSelfWithResult
](
#uiabilitycontextterminateselfwithresult
)
接口使之终止时,只将正常结果返回给最后一个调用方, 其它调用方返回异常信息, 异常信息中resultCode为-1。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录