Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
d1ee8e93
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,发现更多精彩内容 >>
提交
d1ee8e93
编写于
5月 06, 2023
作者:
X
xinking129
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add doc
Signed-off-by:
N
xinking129
<
xinxin13@huawei.com
>
上级
d318f2d3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
153 addition
and
1 deletion
+153
-1
zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md
...apis/js-apis-inner-application-serviceExtensionContext.md
+76
-1
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
...erence/apis/js-apis-inner-application-uiAbilityContext.md
+77
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md
浏览文件 @
d1ee8e93
...
...
@@ -1353,4 +1353,79 @@ startAbilityByCall(want: Want): Promise<Caller>;
// 处理入参错误异常
console
.
error
(
'
error.code: ${paramError.code}, error.message: ${paramError.message}
'
);
}
```
\ No newline at end of file
```
## ServiceExtensionContext.startAbilityByCallWithAccount
startAbilityByCallWithAccount(want: Want, accountId: number): Promise
<
Caller
>
;
根据accountId对指定的Ability进行call调用,并且可以使用返回的Caller通信接口与被调用方进行通信。
使用规则:
-
跨用户场景下,Call调用目标Ability时,调用方应用需同时申请
`ohos.permission.ABILITY_BACKGROUND_COMMUNICATION`
与
`ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS`
权限
-
其他场景下,startAbilityByCallWithAccount接口使用规则与
[
startAbilityByCall使用规则一致
](
#serviceextensioncontextstartabilitybycall
)
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
:此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 传入需要启动的Ability的信息,包含abilityName、moduleName、bundleName、deviceId(可选)、parameters(可选),其中deviceId缺省或为空表示启动本地Ability,parameters缺省或为空表示后台启动Ability。 |
| accountId | number | 是 | 系统帐号的帐号ID,详情参考
[
getCreatedOsAccountsCount
](
js-apis-osAccount.md#getosaccountlocalidfromprocess
)
。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
Caller
>
| 获取要通讯的caller对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | Crowdtest App Expiration. |
| 16000011 | The context does not exist. |
| 16000050 | Internal Error. |
| 16200001 | The caller has been released. |
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
。
**示例:**
```
ts
let
caller
;
// 系统账号的账号ID, -1表示当前激活用户
let
accountId
=
-
1
;
// 指定启动的Ability
let
want
=
{
bundleName
:
'
com.acts.actscalleeabilityrely
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
EntryAbility
'
deviceId
:
''
};
try
{
this
.
context
.
startAbilityByCallWithAccount
(
want
,
accountId
)
.
then
((
obj
)
=>
{
// 执行正常业务
caller
=
obj
;
console
.
log
(
'
startAbilityByCallWithAccount succeed
'
);
}).
catch
((
error
)
=>
{
// 处理业务逻辑错误
console
.
error
(
'
startAbilityByCallWithAccount failed, error.code: ${error.code}, error.message: ${error.message}
'
);
});
}
catch
(
paramError
)
{
// 处理入参错误异常
console
.
error
(
'
error.code: ${paramError.code}, error.message: ${paramError.message}
'
);
}
```
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
浏览文件 @
d1ee8e93
...
...
@@ -2291,3 +2291,80 @@ try {
console
.
error
(
`requestDialogService failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
##
## ServiceExtensionContext.startAbilityByCallWithAccount
startAbilityByCallWithAccount(want: Want, accountId: number): Promise
<
Caller
>
;
根据accountId对指定的Ability进行call调用,并且可以使用返回的Caller通信接口与被调用方进行通信。
使用规则:
-
跨用户场景下,Call调用目标Ability时,调用方应用需同时申请
`ohos.permission.ABILITY_BACKGROUND_COMMUNICATION`
与
`ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS`
权限
-
其他场景下,startAbilityByCallWithAccount接口使用规则与
[
startAbilityByCall使用规则一致
](
#uiabilitycontextstartabilitybycall
)
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
:此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 传入需要启动的Ability的信息,包含abilityName、moduleName、bundleName、deviceId(可选)、parameters(可选),其中deviceId缺省或为空表示启动本地Ability,parameters缺省或为空表示后台启动Ability。 |
| accountId | number | 是 | 系统帐号的帐号ID,详情参考
[
getCreatedOsAccountsCount
](
js-apis-osAccount.md#getosaccountlocalidfromprocess
)
。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
Caller
>
| 获取要通讯的caller对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000001 | Input error. The specified ability name does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Visibility verification failed. |
| 16000005 | Static permission denied. The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | Crowdtest App Expiration. |
| 16000011 | The context does not exist. |
| 16000050 | Internal Error. |
| 16200001 | The caller has been released. |
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
。
**示例:**
```
ts
let
caller
;
// 系统账号的账号ID, -1表示当前激活用户
let
accountId
=
-
1
;
// 指定启动的Ability
let
want
=
{
bundleName
:
'
com.acts.actscalleeabilityrely
'
,
moduleName
:
'
entry
'
,
abilityName
:
'
EntryAbility
'
deviceId
:
''
};
try
{
this
.
context
.
startAbilityByCallWithAccount
(
want
,
accountId
)
.
then
((
obj
)
=>
{
// 执行正常业务
caller
=
obj
;
console
.
log
(
'
startAbilityByCallWithAccount succeed
'
);
}).
catch
((
error
)
=>
{
// 处理业务逻辑错误
console
.
error
(
'
startAbilityByCallWithAccount failed, error.code: ${error.code}, error.message: ${error.message}
'
);
});
}
catch
(
paramError
)
{
// 处理入参错误异常
console
.
error
(
'
error.code: ${paramError.code}, error.message: ${paramError.message}
'
);
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录