Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
3895ad76
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,发现更多精彩内容 >>
提交
3895ad76
编写于
5月 08, 2023
作者:
U
unknown
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add user
Signed-off-by:
N
unknown
<
sijunjie@huawei.com
>
上级
c9adf497
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
406 addition
and
0 deletion
+406
-0
zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md
...apis/js-apis-inner-application-serviceExtensionContext.md
+203
-0
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
...erence/apis/js-apis-inner-application-uiAbilityContext.md
+203
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md
浏览文件 @
3895ad76
...
...
@@ -1353,4 +1353,207 @@ startAbilityByCall(want: Want): Promise<Caller>;
// 处理入参错误异常
console
.
error
(
'
error.code: ${paramError.code}, error.message: ${paramError.message}
'
);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, callback: AsyncCallback
<
void
<
): void;
启动一个指定的Ability,如果这个Ability有多个实例,将拉起最近启动的那个实例。启动结果以callback的形式返回开发者。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
-
跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请
`ohos.permission.START_INVISIBLE_ABILITY`
权限
-
组件启动规则详见:
[
组件启动规则(Stage模型)
](
../../application-models/component-startup-rules.md
)
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 需要启动Ability的want信息。 |
| callback | AsyncCallback
\<
void> | 是 | 指定的回调函数的结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
```
ts
let
want
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
this
.
context
.
startRecentAbility
(
want
,
(
err
)
=>
{
if
(
err
.
code
)
{
// 处理业务逻辑错误
console
.
error
(
`startRecentAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
return
;
}
// 执行正常业务
console
.
info
(
'
startRecentAbility succeed
'
);
});
}
catch
(
err
)
{
// 处理入参错误异常
console
.
error
(
`startRecentAbility failed failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, options: StartOptions, callback: AsyncCallback
<
void
<
): void;
启动一个指定的Ability,如果这个Ability有多个实例,将拉起最近启动的那个实例。启动结果以callback的形式返回开发者。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
-
跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请
`ohos.permission.START_INVISIBLE_ABILITY`
权限
-
组件启动规则详见:
[
组件启动规则(Stage模型)
](
../../application-models/component-startup-rules.md
)
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 需要启动Ability的want信息。 |
| options |
[
StartOptions
](
js-apis-app-ability-startOptions.md
)
| 是 | 启动Ability所携带的参数。 |
| callback | AsyncCallback
\<
void> | 是 | 指定的回调函数的结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
```
ts
let
want
=
{
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
windowMode
:
0
};
try
{
this
.
context
.
startRecentAbility
(
want
,
options
,
(
err
)
=>
{
if
(
err
.
code
)
{
// 处理业务逻辑错误
console
.
error
(
`startRecentAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
return
;
}
// 执行正常业务
console
.
info
(
'
startRecentAbility succeed
'
);
});
}
catch
(
err
)
{
// 处理入参错误异常
console
.
error
(
`startRecentAbility failed failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, options?: StartOptions): Promise
<
void
<
;
启动一个指定的Ability,如果这个Ability有多个实例,将拉起最近启动的那个实例。启动结果以Promise的形式返回开发者。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
-
跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请
`ohos.permission.START_INVISIBLE_ABILITY`
权限
-
组件启动规则详见:
[
组件启动规则(Stage模型)
](
../../application-models/component-startup-rules.md
)
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 需要启动Ability的want信息。 |
| options |
[
StartOptions
](
js-apis-app-ability-startOptions.md
)
| 否 | 启动Ability所携带的参数。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
```
ts
let
want
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
windowMode
:
0
,
};
try
{
this
.
context
.
startRecentAbility
(
want
,
options
)
.
then
(()
=>
{
// 执行正常业务
console
.
info
(
'
startRecentAbility succeed
'
);
})
.
catch
((
err
)
=>
{
// 处理业务逻辑错误
console
.
error
(
`startRecentAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
});
}
catch
(
err
)
{
// 处理入参错误异常
console
.
error
(
`startRecentAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
浏览文件 @
3895ad76
...
...
@@ -2291,3 +2291,206 @@ try {
console
.
error
(
`requestDialogService failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, callback: AsyncCallback
<
void
<
): void;
启动一个指定的Ability,如果这个Ability有多个实例,将拉起最近启动的那个实例。启动结果以callback的形式返回开发者。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
-
跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请
`ohos.permission.START_INVISIBLE_ABILITY`
权限
-
组件启动规则详见:
[
组件启动规则(Stage模型)
](
../../application-models/component-startup-rules.md
)
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 需要启动Ability的want信息。 |
| callback | AsyncCallback
\<
void> | 是 | 指定的回调函数的结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
```
ts
let
want
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
try
{
this
.
context
.
startRecentAbility
(
want
,
(
err
)
=>
{
if
(
err
.
code
)
{
// 处理业务逻辑错误
console
.
error
(
`startRecentAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
return
;
}
// 执行正常业务
console
.
info
(
'
startRecentAbility succeed
'
);
});
}
catch
(
err
)
{
// 处理入参错误异常
console
.
error
(
`startRecentAbility failed failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, options: StartOptions, callback: AsyncCallback
<
void
<
): void;
启动一个指定的Ability,如果这个Ability有多个实例,将拉起最近启动的那个实例。启动结果以callback的形式返回开发者。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
-
跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请
`ohos.permission.START_INVISIBLE_ABILITY`
权限
-
组件启动规则详见:
[
组件启动规则(Stage模型)
](
../../application-models/component-startup-rules.md
)
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 需要启动Ability的want信息。 |
| options |
[
StartOptions
](
js-apis-app-ability-startOptions.md
)
| 是 | 启动Ability所携带的参数。 |
| callback | AsyncCallback
\<
void> | 是 | 指定的回调函数的结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
```
ts
let
want
=
{
deviceId
:
''
,
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
windowMode
:
0
};
try
{
this
.
context
.
startRecentAbility
(
want
,
options
,
(
err
)
=>
{
if
(
err
.
code
)
{
// 处理业务逻辑错误
console
.
error
(
`startRecentAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
return
;
}
// 执行正常业务
console
.
info
(
'
startRecentAbility succeed
'
);
});
}
catch
(
err
)
{
// 处理入参错误异常
console
.
error
(
`startRecentAbility failed failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
## UIAbilityContext.startRecentAbility
startRecentAbility(want: Want, options?: StartOptions): Promise
<
void
<
;
启动一个指定的Ability,如果这个Ability有多个实例,将拉起最近启动的那个实例。启动结果以Promise的形式返回开发者。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
-
跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请
`ohos.permission.START_INVISIBLE_ABILITY`
权限
-
组件启动规则详见:
[
组件启动规则(Stage模型)
](
../../application-models/component-startup-rules.md
)
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 需要启动Ability的want信息。 |
| options |
[
StartOptions
](
js-apis-app-ability-startOptions.md
)
| 否 | 启动Ability所携带的参数。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
| 16200001 | The caller has been released. |
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
```
ts
let
want
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
};
let
options
=
{
windowMode
:
0
,
};
try
{
this
.
context
.
startRecentAbility
(
want
,
options
)
.
then
(()
=>
{
// 执行正常业务
console
.
info
(
'
startRecentAbility succeed
'
);
})
.
catch
((
err
)
=>
{
// 处理业务逻辑错误
console
.
error
(
`startRecentAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
});
}
catch
(
err
)
{
// 处理入参错误异常
console
.
error
(
`startRecentAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录