Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
1829ffc8
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看板
未验证
提交
1829ffc8
编写于
11月 10, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 10, 2022
浏览文件
操作
浏览文件
下载
差异文件
!11150 【元能力】Stage模型ServiceExtensionContext API错误码资料更新
Merge pull request !11150 from HuangXW/ContextErrorCode
上级
0e2d67fe
a224a82f
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
2161 addition
and
603 deletion
+2161
-603
zh-cn/application-dev/ability/stage-call.md
zh-cn/application-dev/ability/stage-call.md
+5
-5
zh-cn/application-dev/reference/apis/js-apis-ability-context.md
...application-dev/reference/apis/js-apis-ability-context.md
+1129
-254
zh-cn/application-dev/reference/apis/js-apis-application-ability.md
...ication-dev/reference/apis/js-apis-application-ability.md
+222
-155
zh-cn/application-dev/reference/apis/js-apis-extension-context.md
...plication-dev/reference/apis/js-apis-extension-context.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md
...n-dev/reference/apis/js-apis-service-extension-context.md
+803
-187
未找到文件。
zh-cn/application-dev/ability/stage-call.md
浏览文件 @
1829ffc8
...
...
@@ -40,7 +40,7 @@ Caller及Callee功能如下:具体的API详见[接口文档](../reference/apis
|call(method: string, data: rpc.Sequenceable): Promise
\<
void>|向通用组件Callee发送约定序列化数据。|
|callWithResult(method: string, data: rpc.Sequenceable): Promise
\<
rpc.MessageParcel>|向通用组件Callee发送约定序列化数据, 并将Callee返回的约定序列化数据带回。|
|release(): void|释放通用组件的Caller通信接口。|
|on
Release(callback: OnReleaseCallB
ack): void|注册通用组件通信断开监听通知。|
|on
(type: "release", callback: OnReleaseCallb
ack): void|注册通用组件通信断开监听通知。|
## 开发步骤
Call调用的开发步骤:
...
...
@@ -72,7 +72,7 @@ Ability配置标签示例如下:
```
**2. 导入Ability模块**
```
ts
import
Ability
from
'
@ohos.app
lication.
Ability
'
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
```
**3. 定义约定的序列化数据**
...
...
@@ -142,7 +142,7 @@ export default class CalleeAbility extends Ability {
### 访问Callee被调用端
**1. 导入Ability模块**
```
ts
import
Ability
from
'
@ohos.app
lication.
Ability
'
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
```
**2. 获取Caller通信接口**
...
...
@@ -151,7 +151,7 @@ import Ability from '@ohos.application.Ability'
// 注册caller的release监听
private
regOnRelease
(
caller
)
{
try
{
caller
.
on
Release
(
(
msg
)
=>
{
caller
.
on
(
"
release
"
,
(
msg
)
=>
{
console
.
log
(
`caller onRelease is called
${
msg
}
`
)
})
console
.
log
(
'
caller register OnRelease succeed
'
)
...
...
@@ -192,7 +192,7 @@ async onButtonGetRemoteCaller() {
caller
=
data
console
.
log
(
'
get remote caller success
'
)
// 注册caller的release监听
caller
.
on
Release
(
(
msg
)
=>
{
caller
.
on
(
"
release
"
,
(
msg
)
=>
{
console
.
log
(
`remote caller onRelease is called
${
msg
}
`
)
})
console
.
log
(
'
remote caller register OnRelease succeed
'
)
...
...
zh-cn/application-dev/reference/apis/js-apis-ability-context.md
浏览文件 @
1829ffc8
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-application-ability.md
浏览文件 @
1829ffc8
...
...
@@ -45,8 +45,8 @@ Ability创建时回调,执行初始化业务逻辑操作。
| param | AbilityConstant.LaunchParam | 是 | 创建
ability、上次异常退出的原因信息。 |
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
onCreate
(
want
,
param
)
{
console
.
log
(
'
onCreate, want:
'
+
want
.
abilityName
);
...
...
@@ -71,7 +71,7 @@ onWindowStageCreate(windowStage: window.WindowStage): void
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
console
.
log
(
'
onWindowStageCreate
'
);
...
...
@@ -90,7 +90,7 @@ onWindowStageDestroy(): void
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
onWindowStageDestroy
()
{
console
.
log
(
'
onWindowStageDestroy
'
);
...
...
@@ -115,7 +115,7 @@ onWindowStageRestore(windowStage: window.WindowStage): void
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
onWindowStageRestore
(
windowStage
)
{
console
.
log
(
'
onWindowStageRestore
'
);
...
...
@@ -134,7 +134,7 @@ Ability生命周期回调,在销毁时回调,执行资源清理等操作。
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
onDestroy
()
{
console
.
log
(
'
onDestroy
'
);
...
...
@@ -153,7 +153,7 @@ Ability生命周期回调,当应用从后台转到前台时触发。
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
onForeground
()
{
console
.
log
(
'
onForeground
'
);
...
...
@@ -172,7 +172,7 @@ Ability生命周期回调,当应用从前台转到后台时触发。
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
onBackground
()
{
console
.
log
(
'
onBackground
'
);
...
...
@@ -203,7 +203,7 @@ onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
**示例:**
```
j
s
```
t
s
import
AbilityConstant
from
"
@ohos.application.AbilityConstant
"
class
myAbility
extends
Ability
{
onContinue
(
wantParams
)
{
...
...
@@ -232,7 +232,7 @@ onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
onNewWant
(
want
)
{
console
.
log
(
'
onNewWant, want:
'
+
want
.
abilityName
);
...
...
@@ -257,7 +257,7 @@ onConfigurationUpdated(config: Configuration): void;
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
onConfigurationUpdated
(
config
)
{
console
.
log
(
'
onConfigurationUpdated, config:
'
+
JSON
.
stringify
(
config
));
...
...
@@ -281,7 +281,7 @@ dump(params: Array\<string>): Array\<string>;
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
dump
(
params
)
{
console
.
log
(
'
dump, params:
'
+
JSON
.
stringify
(
params
));
...
...
@@ -306,7 +306,7 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
**示例:**
```
j
s
```
t
s
class
myAbility
extends
Ability
{
onMemoryLevel
(
level
)
{
console
.
log
(
'
onMemoryLevel, level:
'
+
JSON
.
stringify
(
level
));
...
...
@@ -320,7 +320,6 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
通用组件Caller通信客户端调用接口, 用来向通用组件服务端发送约定数据。
## Caller.call
call(method: string, data: rpc.Sequenceable): Promise
<
void
>
;
...
...
@@ -342,54 +341,65 @@ call(method: string, data: rpc.Sequenceable): Promise<void>;
| -------- | -------- |
| Promise
<
void
>
| Promise形式返回应答。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16200001 | Caller released. The caller has been released. |
| 16200002 | Callee invalid. The callee does not exist. |
| 16000050 | Internal Error. |
**示例:**
```
j
s
import
Ability
from
'
@ohos.app
lication.
Ability
'
;
```
t
s
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
;
class
MyMessageAble
{
// 自定义的Sequenceable数据结构
name
:
""
str
:
""
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
this
.
str
=
str
;
}
marshalling
(
messageParcel
)
{
messageParcel
.
writeInt
(
this
.
num
);
messageParcel
.
writeString
(
this
.
str
);
console
.
log
(
'
MyMessageAble marshalling num[
'
+
this
.
num
+
'
] str[
'
+
this
.
str
+
'
]
'
);
return
true
;
}
unmarshalling
(
messageParcel
)
{
this
.
num
=
messageParcel
.
readInt
();
this
.
str
=
messageParcel
.
readString
();
console
.
log
(
'
MyMessageAble unmarshalling num[
'
+
this
.
num
+
'
] str[
'
+
this
.
str
+
'
]
'
);
return
true
;
}
name
:
""
str
:
""
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
this
.
str
=
str
;
}
marshalling
(
messageParcel
)
{
messageParcel
.
writeInt
(
this
.
num
);
messageParcel
.
writeString
(
this
.
str
);
console
.
log
(
'
MyMessageAble marshalling num[
'
+
this
.
num
+
'
] str[
'
+
this
.
str
+
'
]
'
);
return
true
;
}
unmarshalling
(
messageParcel
)
{
this
.
num
=
messageParcel
.
readInt
();
this
.
str
=
messageParcel
.
readString
();
console
.
log
(
'
MyMessageAble unmarshalling num[
'
+
this
.
num
+
'
] str[
'
+
this
.
str
+
'
]
'
);
return
true
;
}
};
var
method
=
'
call_Function
'
;
// 约定的通知消息字符串
var
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
}).
then
((
obj
)
=>
{
caller
=
obj
;
let
msg
=
new
MyMessageAble
(
1
,
"
world
"
);
// 参考Sequenceable数据定义
caller
.
call
(
method
,
msg
)
.
then
(()
=>
{
console
.
log
(
'
Caller call() called
'
);
}).
catch
((
e
)
=>
{
console
.
log
(
'
Caller call() catch error
'
+
e
);
});
console
.
log
(
'
Caller GetCaller Get
'
+
caller
);
}).
catch
((
e
)
=>
{
console
.
log
(
'
Caller GetCaller error
'
+
e
);
});
}
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
}).
then
((
obj
)
=>
{
caller
=
obj
;
let
msg
=
new
MyMessageAble
(
"
msg
"
,
"
world
"
);
// 参考Sequenceable数据定义
caller
.
call
(
method
,
msg
)
.
then
(()
=>
{
console
.
log
(
'
Caller call() called
'
);
})
.
catch
((
callErr
)
=>
{
console
.
log
(
'
Caller.call catch error, error.code:
'
+
JSON
.
stringify
(
callErr
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
callErr
.
message
));
});
}).
catch
((
err
)
=>
{
console
.
log
(
'
Caller GetCaller error, error.code:
'
+
JSON
.
stringify
(
err
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
err
.
message
));
});
}
}
```
...
...
@@ -415,55 +425,67 @@ callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessagePa
| -------- | -------- |
| Promise
<
rpc.MessageParcel
>
| Promise形式返回通用组件服务端应答数据。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 201 | The application does not have permission to call the interface. |
| 401 | Invalid input parameter. |
| 16200001 | Caller released. The caller has been released. |
| 16200002 | Callee invalid. The callee does not exist. |
| 16000050 | Internal Error. |
**示例:**
```
j
s
import
Ability
from
'
@ohos.app
lication.
Ability
'
;
```
t
s
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
;
class
MyMessageAble
{
name
:
""
str
:
""
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
this
.
str
=
str
;
}
marshalling
(
messageParcel
)
{
messageParcel
.
writeInt
(
this
.
num
);
messageParcel
.
writeString
(
this
.
str
);
console
.
log
(
'
MyMessageAble marshalling num[
'
+
this
.
num
+
'
] str[
'
+
this
.
str
+
'
]
'
);
return
true
;
}
unmarshalling
(
messageParcel
)
{
this
.
num
=
messageParcel
.
readInt
();
this
.
str
=
messageParcel
.
readString
();
console
.
log
(
'
MyMessageAble unmarshalling num[
'
+
this
.
num
+
'
] str[
'
+
this
.
str
+
'
]
'
);
return
true
;
}
name
:
""
str
:
""
num
:
1
constructor
(
name
,
str
)
{
this
.
name
=
name
;
this
.
str
=
str
;
}
marshalling
(
messageParcel
)
{
messageParcel
.
writeInt
(
this
.
num
);
messageParcel
.
writeString
(
this
.
str
);
console
.
log
(
'
MyMessageAble marshalling num[
'
+
this
.
num
+
'
] str[
'
+
this
.
str
+
'
]
'
);
return
true
;
}
unmarshalling
(
messageParcel
)
{
this
.
num
=
messageParcel
.
readInt
();
this
.
str
=
messageParcel
.
readString
();
console
.
log
(
'
MyMessageAble unmarshalling num[
'
+
this
.
num
+
'
] str[
'
+
this
.
str
+
'
]
'
);
return
true
;
}
};
var
method
=
'
call_Function
'
;
var
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
}).
then
((
obj
)
=>
{
caller
=
obj
;
let
msg
=
new
MyMessageAble
(
1
,
"
world
"
);
caller
.
callWithResult
(
method
,
msg
)
.
then
((
data
)
=>
{
console
.
log
(
'
Caller callWithResult() called
'
);
let
retmsg
=
new
MyMessageAble
(
0
,
""
);
data
.
readSequenceable
(
retmsg
);
}).
catch
((
e
)
=>
{
console
.
log
(
'
Caller callWithResult() catch error
'
+
e
);
});
console
.
log
(
'
Caller GetCaller Get
'
+
caller
);
}).
catch
((
e
)
=>
{
console
.
log
(
'
Caller GetCaller error
'
+
e
);
});
}
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
}).
then
((
obj
)
=>
{
caller
=
obj
;
let
msg
=
new
MyMessageAble
(
1
,
"
world
"
);
caller
.
callWithResult
(
method
,
msg
)
.
then
((
data
)
=>
{
console
.
log
(
'
Caller callWithResult() called
'
);
let
retmsg
=
new
MyMessageAble
(
0
,
""
);
data
.
readSequenceable
(
retmsg
);
})
.
catch
((
callErr
)
=>
{
console
.
log
(
'
Caller.callWithResult catch error, error.code:
'
+
JSON
.
stringify
(
callErr
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
callErr
.
message
));
});
}).
catch
((
err
)
=>
{
console
.
log
(
'
Caller GetCaller error, error.code:
'
+
JSON
.
stringify
(
err
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
err
.
message
));
});
}
}
```
...
...
@@ -476,36 +498,46 @@ release(): void;
**系统能力**
:SystemCapability.Ability.AbilityRuntime.AbilityCore
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 401 | Invalid input parameter. |
| 16200001 | Caller released. The caller has been released. |
| 16200002 | Callee invalid. The callee does not exist. |
| 16000050 | Internal Error. |
**示例:**
```
j
s
import
Ability
from
'
@ohos.app
lication.
Ability
'
;
```
t
s
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
;
var
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
caller
.
release
();
}
catch
(
e
)
{
console
.
log
(
'
Caller Release error
'
+
e
);
}
console
.
log
(
'
Caller GetCaller Get
'
+
caller
);
}).
catch
((
e
)
=>
{
console
.
log
(
'
Caller GetCaller error
'
+
e
);
});
}
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
caller
.
release
();
}
catch
(
releaseErr
)
{
console
.
log
(
'
Caller.release catch error, error.code:
'
+
JSON
.
stringify
(
releaseErr
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
releaseErr
.
message
));
}
}).
catch
((
err
)
=>
{
console
.
log
(
'
Caller GetCaller error, error.code:
'
+
JSON
.
stringify
(
err
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
err
.
message
));
});
}
}
```
## Caller.on
Release
## Caller.on
onRelease(callback: OnReleaseCallB
ack): void;
on(type: "release", callback: OnReleaseCallb
ack): void;
注册通用组件服务端Stub(桩)断开监听通知。
...
...
@@ -515,33 +547,43 @@ onRelease(callback: OnReleaseCallBack): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听releaseCall事件,固定为'release'。 |
| callback | OnReleaseCallBack | 是 | 返回onRelease回调结果。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 401 | Invalid input parameter. |
| 16200001 | Caller released. The caller has been released. |
| 16000050 | Internal Error. |
**示例:**
```
j
s
import
Ability
from
'
@ohos.app
lication.
Ability
'
;
```
t
s
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
;
var
caller
;
export
default
class
MainAbility
extends
Ability
{
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
caller
.
onRelease
((
str
)
=>
{
console
.
log
(
'
Caller OnRelease CallBack is called
'
+
str
);
});
}
catch
(
e
)
{
console
.
log
(
'
Caller Release error
'
+
e
);
}
console
.
log
(
'
Caller GetCaller Get
'
+
caller
);
}).
catch
((
e
)
=>
{
console
.
log
(
'
Caller GetCaller error
'
+
e
);
});
}
onWindowStageCreate
(
windowStage
)
{
this
.
context
.
startAbilityByCall
({
bundleName
:
"
com.example.myservice
"
,
abilityName
:
"
MainAbility
"
,
deviceId
:
""
}).
then
((
obj
)
=>
{
caller
=
obj
;
try
{
caller
.
on
(
"
release
"
,
(
str
)
=>
{
console
.
log
(
'
Caller OnRelease CallBack is called
'
+
str
);
});
}
catch
(
error
)
{
console
.
log
(
'
Caller.on catch error, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
}).
catch
((
err
)
=>
{
console
.
log
(
'
Caller GetCaller error, error.code:
'
+
JSON
.
stringify
(
err
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
err
.
message
));
});
}
}
```
...
...
@@ -550,7 +592,6 @@ onRelease(callback: OnReleaseCallBack): void;
通用组件服务端注册和解除客户端caller通知送信的callback接口。
## Callee.on
on(method: string, callback: CalleeCallBack): void;
...
...
@@ -566,10 +607,18 @@ on(method: string, callback: CalleeCallBack): void;
| method | string | 是 | 与客户端约定的通知消息字符串。 |
| callback | CalleeCallBack | 是 | 一个rpc.MessageParcel类型入参的js通知同步回调函数,
回调函数至少要返回一个空的rpc.Sequenceable数据对象,
其他视为函数执行错误。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 401 | Invalid input parameter. |
| 16200004 | Method registered. The method has registered. |
| 16000050 | Internal Error. |
**示例:**
```
j
s
import
Ability
from
'
@ohos.app
lication.
Ability
'
;
```
t
s
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
;
class
MyMessageAble
{
name
:
""
str
:
""
...
...
@@ -599,14 +648,18 @@ on(method: string, callback: CalleeCallBack): void;
return
new
MyMessageAble
(
10
,
"
Callee test
"
);
}
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
Callee onCreate is called
'
);
this
.
callee
.
on
(
method
,
funcCallBack
);
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
Callee onCreate is called
'
);
try
{
this
.
callee
.
on
(
method
,
funcCallBack
);
}
catch
(
error
)
{
console
.
log
(
'
Callee.on catch error, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
}
}
```
## Callee.off
off(method: string): void;
...
...
@@ -621,20 +674,34 @@ off(method: string): void;
| -------- | -------- | -------- | -------- |
| method | string | 是 | 已注册的通知事件字符串。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 401 | Invalid input parameter. |
| 16200005 | Method not registered. The method has not registered. |
| 16000050 | Internal Error. |
**示例:**
```
j
s
import
Ability
from
'
@ohos.app
lication.
Ability
'
;
```
t
s
import
Ability
from
'
@ohos.app
.ability.UI
Ability
'
;
var
method
=
'
call_Function
'
;
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
Callee onCreate is called
'
);
this
.
callee
.
off
(
method
);
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
Callee onCreate is called
'
);
try
{
this
.
callee
.
off
(
method
);
}
catch
(
error
)
{
console
.
log
(
'
Callee.off catch error, error.code:
'
+
JSON
.
stringify
(
error
.
code
)
+
'
error.message:
'
+
JSON
.
stringify
(
error
.
message
));
}
}
}
```
## OnReleaseCall
B
ack
## OnReleaseCall
b
ack
(msg: string): void;
...
...
@@ -644,7 +711,7 @@ off(method: string): void;
| -------- | -------- | -------- | -------- | -------- |
| (msg: string) | function | 是 | 否 | 调用者注册的侦听器函数接口的原型。 |
## CalleeCall
B
ack
## CalleeCall
b
ack
(indata: rpc.MessageParcel): rpc.Sequenceable;
...
...
zh-cn/application-dev/reference/apis/js-apis-extension-context.md
浏览文件 @
1829ffc8
...
...
@@ -31,7 +31,7 @@ ExtensionContext主要用于查询所属Extension的信息、Module的配置信
三个Module内都定义一个相同名称的ServiceExtension:
```
js
import
ServiceExtension
from
'
@ohos.app
lication
.ServiceExtensionAbility
'
import
ServiceExtension
from
'
@ohos.app
.ability
.ServiceExtensionAbility
'
import
Want
from
'
@ohos.application.Want
'
export
default
class
TheServiceExtension
extends
ServiceExtension
{
onCreate
(
want
:
Want
)
{
...
...
@@ -61,7 +61,7 @@ export default class TheServiceExtension extends ServiceExtension {
在entry的MainAbility的onCreate回调内启动ServiceExtension
```
js
import
Ability
from
'
@ohos.app
lication
.Ability
'
import
Ability
from
'
@ohos.app
.ability
.Ability
'
export
default
class
MainAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
console
.
log
(
"
[Demo] MainAbility onCreate
"
);
...
...
zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md
浏览文件 @
1829ffc8
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录