Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
28d8ec23
D
Docs
项目概览
OpenHarmony
/
Docs
接近 2 年 前同步成功
通知
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看板
未验证
提交
28d8ec23
编写于
5月 18, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 18, 2023
浏览文件
操作
浏览文件
下载
差异文件
!18014 静态订阅Extension支持context相关docs代码提交
Merge pull request !18014 from xinking129/master
上级
b7fa4bdc
d9092e2c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
188 addition
and
0 deletion
+188
-0
zh-cn/application-dev/reference/apis/Readme-CN.md
zh-cn/application-dev/reference/apis/Readme-CN.md
+1
-0
zh-cn/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md
...s/js-apis-application-StaticSubscriberExtensionContext.md
+161
-0
zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
...s/js-apis-application-staticSubscriberExtensionAbility.md
+8
-0
zh-cn/application-dev/reference/errorcodes/errorcode-ability.md
...application-dev/reference/errorcodes/errorcode-ability.md
+18
-0
未找到文件。
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
28d8ec23
...
@@ -120,6 +120,7 @@
...
@@ -120,6 +120,7 @@
-
[
@ohos.events.emitter (Emitter)
](
js-apis-emitter.md
)
-
[
@ohos.events.emitter (Emitter)
](
js-apis-emitter.md
)
-
[
@ohos.notificationManager (NotificationManager模块)(推荐)
](
js-apis-notificationManager.md
)
-
[
@ohos.notificationManager (NotificationManager模块)(推荐)
](
js-apis-notificationManager.md
)
-
[
@ohos.notificationSubscribe (NotificationSubscribe模块)(推荐)
](
js-apis-notificationSubscribe.md
)
-
[
@ohos.notificationSubscribe (NotificationSubscribe模块)(推荐)
](
js-apis-notificationSubscribe.md
)
-
[
@ohos.application.StaticSubscriberExtensionContext (NotificationSubscribe模块)(推荐)
](
js-apis-application-StaticSubscriberExtensionContext.md
)
-
[
系统公共事件定义 (待停用)
](
commonEvent-definitions.md
)
-
[
系统公共事件定义 (待停用)
](
commonEvent-definitions.md
)
-
[
@ohos.commonEvent (公共事件模块)(待停用)
](
js-apis-commonEvent.md
)
-
[
@ohos.commonEvent (公共事件模块)(待停用)
](
js-apis-commonEvent.md
)
-
[
@ohos.notification (Notification模块)(待停用)
](
js-apis-notification.md
)
-
[
@ohos.notification (Notification模块)(待停用)
](
js-apis-notification.md
)
...
...
zh-cn/application-dev/reference/apis/js-apis-application-StaticSubscriberExtensionContext.md
0 → 100644
浏览文件 @
28d8ec23
# @ohos.application.StaticSubscriberExtensionContext (StaticSubscriberExtensionContext)
StaticSubscriberExtensionContext模块是StaticSubscriberExtensionAbility的上下文环境,继承自ExtensionContext。
StaticSubscriberExtensionContext模块提供StaticSubscriberExtensionAbility具有的接口和能力。
> **说明:**
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块接口仅可在Stage模型下使用。
## 使用说明
在使用StaticSubscriberExtensionContext的功能前,需要通过StaticSubscriberExtensionAbility获取。
```
ts
import
StaticSubscriberExtensionAbility
from
'
@ohos.application.StaticSubscriberExtensionAbility
'
export
default
class
MyStaticSubscriberExtensionAbility
extends
StaticSubscriberExtensionAbility
{
context
=
this
.
context
;
};
```
## StaticSubscriberExtensionContext.startAbility
startAbility(want: Want, callback: AsyncCallback
<
void
>
): void;
拉起一个静态订阅所属的同应用的Ability。使用callback异步回调。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
-
跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请
`ohos.permission.START_INVISIBLE_ABILITY`
权限
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
:该接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | -------------------------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
| callback | AsyncCallback
<
void
>
| 是 | callback形式返回启动结果。 |
**错误码:**
以下错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
。
| 错误码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. |
| 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. |
| 16300003 | The target application is not self application. |
**示例:**
```
ts
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
};
try
{
this
.
context
.
startAbility
(
want
,
(
error
)
=>
{
if
(
error
)
{
// 处理业务逻辑错误
console
.
log
(
'
startAbility failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
return
;
}
// 执行正常业务
console
.
log
(
'
startAbility succeed
'
);
});
}
catch
(
paramError
)
{
// 处理入参错误异常
console
.
log
(
'
startAbility failed, error.code:
'
+
JSON
.
stringify
(
paramError
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
paramError
.
message
));
}
```
## StaticSubscriberExtensionContext.startAbility
startAbility(want: Want): Promise
<
void
>
;
拉起一个静态订阅所属的同应用的Ability。使用Promise异步回调。
使用规则:
-
调用方应用位于后台时,使用该接口启动Ability需申请
`ohos.permission.START_ABILITIES_FROM_BACKGROUND`
权限
-
跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请
`ohos.permission.START_INVISIBLE_ABILITY`
权限
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
:该接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------------- | ---- | ----------------------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 启动Ability的want信息。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| Promise形式返回启动结果。 |
**错误码:**
以下错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
。
| 错误码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. |
| 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. |
| 16300003 | The target application is not self application. |
**示例:**
```
ts
let
want
=
{
bundleName
:
"
com.example.myapp
"
,
abilityName
:
"
MyAbility
"
};
try
{
this
.
context
.
startAbility
(
want
)
.
then
(()
=>
{
// 执行正常业务
console
.
log
(
'
startAbility succeed
'
);
})
.
catch
((
error
)
=>
{
// 处理业务逻辑错误
console
.
log
(
'
startAbility failed, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
});
}
catch
(
paramError
)
{
// 处理入参错误异常
console
.
log
(
'
startAbility failed, error.code:
'
+
JSON
.
stringify
(
paramError
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
paramError
.
message
));
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
浏览文件 @
28d8ec23
...
@@ -12,6 +12,14 @@ StaticSubscriberExtensionAbility模块提供静态订阅者ExtensionAbility的
...
@@ -12,6 +12,14 @@ StaticSubscriberExtensionAbility模块提供静态订阅者ExtensionAbility的
import
StaticSubscriberExtensionAbility
from
'
@ohos.application.StaticSubscriberExtensionAbility
'
;
import
StaticSubscriberExtensionAbility
from
'
@ohos.application.StaticSubscriberExtensionAbility
'
;
```
```
## 属性
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.AbilityCore
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------- | ------------------------------------------------------------ | ---- | ---- | -------- |
| context |
[
StaticSubscriberExtensionContext
](
js-apis-application-StaticSubscriberExtensionContext.md
)
| 是 | 否 | 上下文。 |
## StaticSubscriberExtensionAbility.onReceiveEvent
## StaticSubscriberExtensionAbility.onReceiveEvent
onReceiveEvent(event: CommonEventData): void;
onReceiveEvent(event: CommonEventData): void;
...
...
zh-cn/application-dev/reference/errorcodes/errorcode-ability.md
浏览文件 @
28d8ec23
...
@@ -583,6 +583,24 @@ The specified mission listener does not exist.
...
@@ -583,6 +583,24 @@ The specified mission listener does not exist.
确认操作的任务监听器是否存在。
确认操作的任务监听器是否存在。
## 16300003 目标应用程序不是自身应用程序
**错误信息**
The target application is not self application.
**错误描述**
当被拉起的应用程序不是自身应用程序时,方法将返回该错误码。
**可能原因**
被拉起的应用和发起调用的应用不是同一个应用程序。
**处理步骤**
确认被拉起的应用程序是否为自身应用程序。
## 18500001 指定的包名无效
## 18500001 指定的包名无效
**错误信息**
**错误信息**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录