Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
e67e20dd
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,发现更多精彩内容 >>
未验证
提交
e67e20dd
编写于
3月 24, 2023
作者:
O
openharmony_ci
提交者:
Gitee
3月 24, 2023
浏览文件
操作
浏览文件
下载
差异文件
!16175 资料描述优化
Merge pull request !16175 from mingxihua/master
上级
49ff07d4
c29c05b0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
6 deletion
+24
-6
zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md
...apis/js-apis-inner-application-serviceExtensionContext.md
+16
-4
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
...erence/apis/js-apis-inner-application-uiAbilityContext.md
+8
-2
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md
浏览文件 @
e67e20dd
...
...
@@ -17,6 +17,7 @@ ServiceExtensionContext模块提供ServiceExtensionAbility具有的能力,包
import
ServiceExtensionAbility
from
'
@ohos.app.ability.ServiceExtensionAbility
'
;
let
context
;
let
commRemote
;
// 断开连接时需要释放
class
EntryAbility
extends
ServiceExtensionAbility
{
onCreate
()
{
context
=
this
.
context
;
// 获取ServiceExtensionContext
...
...
@@ -1093,7 +1094,10 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
abilityName
:
'
MyAbility
'
};
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
)
},
onConnect
(
elementName
,
remote
)
{
commRemote
=
remote
;
console
.
log
(
'
----------- onConnect -----------
'
);
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
)
},
onFailed
(
code
)
{
console
.
error
(
'
----------- onFailed -----------
'
)
}
};
...
...
@@ -1154,7 +1158,10 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
};
let
accountId
=
100
;
let
options
=
{
onConnect
(
elementName
,
remote
)
{
console
.
log
(
'
----------- onConnect -----------
'
);
},
onConnect
(
elementName
,
remote
)
{
commRemote
=
remote
;
console
.
log
(
'
----------- onConnect -----------
'
);
},
onDisconnect
(
elementName
)
{
console
.
log
(
'
----------- onDisconnect -----------
'
);
},
onFailed
(
code
)
{
console
.
log
(
'
----------- onFailed -----------
'
);
}
};
...
...
@@ -1172,7 +1179,7 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback
<
void
>
): void;
将一个Ability与绑定的服务类型的Ability解绑。
将一个Ability与绑定的服务类型的Ability解绑
,断开连接之后需要将连接成功时返回的remote对象置空
。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -1204,6 +1211,7 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback<
try
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
,
(
error
)
=>
{
commRemote
=
null
;
if
(
error
.
code
)
{
// 处理业务逻辑错误
console
.
error
(
'
disconnectServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}
'
);
...
...
@@ -1213,6 +1221,7 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback<
console
.
log
(
'
disconnectServiceExtensionAbility succeed
'
);
});
}
catch
(
paramError
)
{
commRemote
=
null
;
// 处理入参错误异常
console
.
error
(
'
error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}
'
);
}
...
...
@@ -1222,7 +1231,7 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback<
disconnectServiceExtensionAbility(connection: number): Promise
<
void
>
;
将一个Ability与绑定的服务类型的Ability解绑
。通过Promise返回结果
。
将一个Ability与绑定的服务类型的Ability解绑
,断开连接之后需要将连接成功时返回的remote对象置空(Promise形式返回结果)
。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -1260,14 +1269,17 @@ disconnectServiceExtensionAbility(connection: number): Promise<void>;
try
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
)
.
then
((
data
)
=>
{
commRemote
=
null
;
// 执行正常业务
console
.
log
(
'
disconnectServiceExtensionAbility succeed
'
);
})
.
catch
((
error
)
=>
{
commRemote
=
null
;
// 处理业务逻辑错误
console
.
error
(
'
disconnectServiceExtensionAbility failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}
'
);
});
}
catch
(
paramError
)
{
commRemote
=
null
;
// 处理入参错误异常
console
.
error
(
'
error.code: ${JSON.stringify(paramError.code)}, error.message: ${JSON.stringify(paramError.message)}
'
);
}
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md
浏览文件 @
e67e20dd
...
...
@@ -1349,6 +1349,7 @@ let want = {
};
let
options
=
{
onConnect
(
elementName
,
remote
)
{
commRemote
=
remote
;
console
.
info
(
'
onConnect...
'
)
},
onDisconnect
(
elementName
)
{
...
...
@@ -1415,6 +1416,7 @@ let want = {
let
accountId
=
100
;
let
options
=
{
onConnect
(
elementName
,
remote
)
{
commRemote
=
remote
;
console
.
info
(
'
onConnect...
'
)
},
onDisconnect
(
elementName
)
{
...
...
@@ -1438,7 +1440,7 @@ try {
disconnectServiceExtensionAbility(connection: number): Promise
\<
void>;
断开与ServiceExtensionAbility的连接(promise形式)。
断开与ServiceExtensionAbility的连接
,断开连接之后需要将连接成功时返回的remote对象置空
(promise形式)。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -1471,6 +1473,7 @@ let connection = 1;
try
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
,
(
err
)
=>
{
commRemote
=
null
;
if
(
err
.
code
)
{
// 处理业务逻辑错误
console
.
error
(
`disconnectServiceExtensionAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
...
...
@@ -1480,6 +1483,7 @@ try {
console
.
info
(
'
disconnectServiceExtensionAbility succeed
'
);
});
}
catch
(
err
)
{
commRemote
=
null
;
// 处理入参错误异常
console
.
error
(
`disconnectServiceExtensionAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
...
...
@@ -1489,7 +1493,7 @@ try {
disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback
\<
void>): void;
断开与ServiceExtensionAbility的连接(callback形式)。
断开与ServiceExtensionAbility的连接
,断开连接之后需要将连接成功时返回的remote对象置空
(callback形式)。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
...
@@ -1517,6 +1521,7 @@ let connection = 1;
try
{
this
.
context
.
disconnectServiceExtensionAbility
(
connection
,
(
err
)
=>
{
commRemote
=
null
;
if
(
err
.
code
)
{
// 处理业务逻辑错误
console
.
error
(
`disconnectServiceExtensionAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
...
...
@@ -1526,6 +1531,7 @@ try {
console
.
info
(
'
disconnectServiceExtensionAbility succeed
'
);
});
}
catch
(
err
)
{
commRemote
=
null
;
// 处理入参错误异常
console
.
error
(
`disconnectServiceExtensionAbility failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录