Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
2aef369a
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看板
未验证
提交
2aef369a
编写于
11月 22, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
!10031 FeatureAbility和Context接口示例问题修改
Merge pull request !10031 from dy/master
上级
5c26b819
47219393
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
220 addition
and
245 deletion
+220
-245
zh-cn/application-dev/ability/context-userguide.md
zh-cn/application-dev/ability/context-userguide.md
+5
-5
zh-cn/application-dev/ability/fa-serviceability.md
zh-cn/application-dev/ability/fa-serviceability.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-Context.md
zh-cn/application-dev/reference/apis/js-apis-Context.md
+132
-159
zh-cn/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md
...reference/apis/js-apis-application-EnvironmentCallback.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
...ence/apis/js-apis-application-abilityLifecycleCallback.md
+9
-3
zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md
.../reference/apis/js-apis-application-applicationContext.md
+7
-7
zh-cn/application-dev/reference/apis/js-apis-featureAbility.md
.../application-dev/reference/apis/js-apis-featureAbility.md
+55
-59
zh-cn/application-dev/reference/apis/js-apis-particleAbility.md
...application-dev/reference/apis/js-apis-particleAbility.md
+6
-6
未找到文件。
zh-cn/application-dev/ability/context-userguide.md
浏览文件 @
2aef369a
...
...
@@ -94,13 +94,13 @@ export default {
**示例**
```
javascript
import
Ability
Stage
from
"
@ohos.application.AbilityStage
"
;
import
Ability
from
"
@ohos.application.Ability
"
;
var
lifecycleid
;
export
default
class
M
yAbilityStage
extends
AbilityStage
{
export
default
class
M
ainAbility
extends
Ability
{
onCreate
()
{
console
.
log
(
"
M
yAbilityStage
onCreate
"
)
console
.
log
(
"
M
ainAbility
onCreate
"
)
let
AbilityLifecycleCallback
=
{
onAbilityCreate
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityCreate ability:
"
+
JSON
.
stringify
(
ability
));
...
...
@@ -139,11 +139,11 @@ export default class MyAbilityStage extends AbilityStage {
// 2.通过applicationContext注册监听应用内生命周期
lifecycleid
=
applicationContext
.
registerAbilityLifecycleCallback
(
AbilityLifecycleCallback
);
console
.
log
(
"
registerAbilityLifecycleCallback number:
"
+
JSON
.
stringify
(
lifecycleid
));
}
}
,
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
unregisterAbilityLifecycleCallback
(
lifecycleid
,
(
error
,
data
)
=>
{
console
.
log
(
"
unregisterAbilityLifecycleCallback success, err:
"
+
JSON
.
stringify
(
error
));
console
.
log
(
"
unregisterAbilityLifecycleCallback success, err:
"
+
JSON
.
stringify
(
error
));
});
}
}
...
...
zh-cn/application-dev/ability/fa-serviceability.md
浏览文件 @
2aef369a
...
...
@@ -128,7 +128,7 @@ let promise = featureAbility.startAbility(
使用OpenHarmony IDL(OpenHarmony Interface Definition Language)来自动生成对应客户端服务端及IRemoteObject代码,具体示例代码和说明请参考:
-
[
`OpenHarmony IDL`:TS开发步骤
](
https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/IDL/idl-guidelines.md#ts
开发步骤
)
-
[
`OpenHarmony IDL`:TS开发步骤
](
https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/IDL/idl-guidelines.md#ts
%E5%BC%80%E5%8F%91%E6%AD%A5%E9%AA%A4
)
2.
在对应文件编写代码
...
...
@@ -176,7 +176,7 @@ let promise = featureAbility.startAbility(
```javascript
import featureAbility from '@ohos.ability.featureAbility';
let connId = featureAbility.connectAbility(
let conn
ect
Id = featureAbility.connectAbility(
{
bundleName: "com.jstest.service",
abilityName: "com.jstest.service.ServiceAbility",
...
...
@@ -293,7 +293,7 @@ function getRemoteDeviceId() {
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
connId
=
featureAbility
.
connectAbility
(
let
conn
ect
Id
=
featureAbility
.
connectAbility
(
{
deviceId
:
getRemoteDeviceId
(),
bundleName
:
"
ohos.samples.etsDemo
"
,
...
...
zh-cn/application-dev/reference/apis/js-apis-Context.md
浏览文件 @
2aef369a
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md
浏览文件 @
2aef369a
...
...
@@ -33,13 +33,13 @@ onConfigurationUpdated(config: Configuration): void;
```
js
import
Ability
Stage
from
"
@ohos.application.AbilityStage
"
;
import
Ability
from
"
@ohos.application.Ability
"
;
var
callbackId
;
export
default
class
MyAbility
Stage
extends
AbilityStage
{
export
default
class
MyAbility
extends
Ability
{
onCreate
()
{
console
.
log
(
"
MyAbility
Stage
onCreate
"
)
console
.
log
(
"
MyAbility onCreate
"
)
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
let
EnvironmentCallback
=
{
onConfigurationUpdated
(
config
){
...
...
zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
浏览文件 @
2aef369a
...
...
@@ -157,11 +157,11 @@ onAbilityContinue(ability: Ability): void;
```
js
import
Ability
Stage
from
"
@ohos.application.AbilityStage
"
;
import
Ability
from
"
@ohos.application.Ability
"
;
export
default
class
MyAbility
Stage
extends
AbilityStage
{
export
default
class
MyAbility
extends
Ability
{
onCreate
()
{
console
.
log
(
"
MyAbility
Stage
onCreate
"
)
console
.
log
(
"
MyAbility onCreate
"
)
let
AbilityLifecycleCallback
=
{
onAbilityCreate
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityCreate ability:
"
+
JSON
.
stringify
(
ability
));
...
...
@@ -200,6 +200,12 @@ onAbilityContinue(ability: Ability): void;
// 2.通过applicationContext注册监听应用内生命周期
let
lifecycleid
=
applicationContext
.
registerAbilityLifecycleCallback
(
AbilityLifecycleCallback
);
console
.
log
(
"
registerAbilityLifecycleCallback number:
"
+
JSON
.
stringify
(
lifecycleid
));
},
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
unregisterAbilityLifecycleCallback
(
lifecycleid
,
(
error
,
data
)
=>
{
console
.
log
(
"
unregisterAbilityLifecycleCallback success, err:
"
+
JSON
.
stringify
(
error
));
});
}
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md
浏览文件 @
2aef369a
...
...
@@ -39,13 +39,13 @@ registerAbilityLifecycleCallback(callback: AbilityLifecycleCallback): **number**
**示例:**
```
js
import
Ability
Stage
from
"
@ohos.application.AbilityStage
"
;
import
Ability
from
"
@ohos.application.Ability
"
;
var
lifecycleId
;
export
default
class
MyAbility
Stage
extends
AbilityStage
{
export
default
class
MyAbility
extends
Ability
{
onCreate
()
{
console
.
log
(
"
MyAbility
Stage
onCreate
"
)
console
.
log
(
"
MyAbility onCreate
"
)
let
AbilityLifecycleCallback
=
{
onAbilityCreate
(
ability
){
console
.
log
(
"
AbilityLifecycleCallback onAbilityCreate ability:
"
+
JSON
.
stringify
(
ability
));
...
...
@@ -84,7 +84,7 @@ export default class MyAbilityStage extends AbilityStage {
// 2.通过applicationContext注册监听应用内生命周期
lifecycleId
=
applicationContext
.
registerAbilityLifecycleCallback
(
AbilityLifecycleCallback
);
console
.
log
(
"
registerAbilityLifecycleCallback number:
"
+
JSON
.
stringify
(
lifecycleId
));
}
}
,
onDestroy
()
{
let
applicationContext
=
this
.
context
.
getApplicationContext
();
applicationContext
.
unregisterAbilityLifecycleCallback
(
lifecycleId
,
(
error
,
data
)
=>
{
...
...
@@ -144,13 +144,13 @@ registerEnvironmentCallback(callback: EnvironmentCallback): **number**;
**示例:**
```
js
import
Ability
Stage
from
"
@ohos.application.AbilityStage
"
;
import
Ability
from
"
@ohos.application.Ability
"
;
var
callbackId
;
export
default
class
MyAbility
Stage
extends
AbilityStage
{
export
default
class
MyAbility
extends
Ability
{
onCreate
()
{
console
.
log
(
"
MyAbility
Stage
onCreate
"
)
console
.
log
(
"
MyAbility onCreate
"
)
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
let
EnvironmentCallback
=
{
onConfigurationUpdated
(
config
){
...
...
zh-cn/application-dev/reference/apis/js-apis-featureAbility.md
浏览文件 @
2aef369a
...
...
@@ -14,7 +14,7 @@ FeatureAbility模块的接口只能在Page类型的Ability调用
## 导入模块
```
import featureAbility from '@ohos.ability.featureAbility'
import featureAbility from '@ohos.ability.featureAbility'
;
```
## featureAbility.startAbility
...
...
@@ -35,8 +35,8 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<number>)
**示例:**
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
wantConstant
from
'
@ohos.ability.wantConstant
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
wantConstant
from
'
@ohos.ability.wantConstant
'
;
featureAbility
.
startAbility
(
{
want
:
...
...
@@ -53,7 +53,7 @@ featureAbility.startAbility(
},
},
(
err
,
data
)
=>
{
console
.
info
(
"
err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
))
console
.
info
(
"
startAbility err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
}
);
```
...
...
@@ -77,8 +77,8 @@ startAbility(parameter: StartAbilityParameter): Promise\<number>
**示例:**
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
wantConstant
from
'
@ohos.ability.wantConstant
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
wantConstant
from
'
@ohos.ability.wantConstant
'
;
featureAbility
.
startAbility
(
{
want
:
...
...
@@ -86,7 +86,7 @@ featureAbility.startAbility(
action
:
"
action.system.home
"
,
entities
:
[
"
entity.system.home
"
],
type
:
"
MIMETYPE
"
,
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
flags
:
wantConstant
.
Flags
.
FLAG_AUTH_READ_URI_PERMISSION
,
deviceId
:
""
,
bundleName
:
"
com.example.myapplication
"
,
/* FA模型中abilityName由package + Ability name组成 */
...
...
@@ -95,7 +95,7 @@ featureAbility.startAbility(
},
}
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>startAbility=======================>
"
);
console
.
info
(
"
startAbility data:
"
+
JSON
.
stringify
(
data
)
);
});
```
...
...
@@ -122,10 +122,10 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper
**示例:**
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
featureAbility
.
acquireDataAbilityHelper
(
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
dataAbilityHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
)
)
;
```
## featureAbility.startAbilityForResult<sup>7+</sup>
...
...
@@ -147,7 +147,7 @@ startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
wantConstant
from
'
@ohos.ability.wantConstant
'
import
wantConstant
from
'
@ohos.ability.wantConstant
'
;
featureAbility
.
startAbilityForResult
(
{
want
:
...
...
@@ -164,9 +164,9 @@ featureAbility.startAbilityForResult(
},
},
(
err
,
data
)
=>
{
console
.
info
(
"
err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
))
console
.
info
(
"
startAbilityForResult err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
}
)
)
;
```
## featureAbility.startAbilityForResult<sup>7+</sup>
...
...
@@ -193,7 +193,7 @@ startAbilityForResult(parameter: StartAbilityParameter): Promise\<AbilityResult>
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
wantConstant
from
'
@ohos.ability.wantConstant
'
import
wantConstant
from
'
@ohos.ability.wantConstant
'
;
featureAbility
.
startAbilityForResult
(
{
want
:
...
...
@@ -221,7 +221,7 @@ featureAbility.startAbilityForResult(
},
},
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>startAbilityForResult=======================>
"
);
console
.
info
(
"
startAbilityForResult data:
"
+
JSON
.
stringify
(
data
)
);
});
```
...
...
@@ -243,8 +243,8 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\<void>
**示例:**
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
wantConstant
from
'
@ohos.ability.wantConstant
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
wantConstant
from
'
@ohos.ability.wantConstant
'
;
featureAbility
.
terminateSelfWithResult
(
{
resultCode
:
1
,
...
...
@@ -301,7 +301,7 @@ terminateSelfWithResult(parameter: AbilityResult): Promise\<void>
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
wantConstant
from
'
@ohos.ability.wantConstant
'
import
wantConstant
from
'
@ohos.ability.wantConstant
'
;
featureAbility
.
terminateSelfWithResult
(
{
resultCode
:
1
,
...
...
@@ -351,11 +351,9 @@ hasWindowFocus(callback: AsyncCallback\<boolean>): void
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
hasWindowFocus
(
(
err
,
data
)
=>
{
console
.
info
(
"
err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
))
}
)
featureAbility
.
hasWindowFocus
((
err
,
data
)
=>
{
console
.
info
(
"
hasWindowFocus err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
```
## featureAbility.hasWindowFocus<sup>7+<sup>
...
...
@@ -377,7 +375,7 @@ hasWindowFocus(): Promise\<boolean>
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
hasWindowFocus
().
then
((
data
)
=>
{
console
.
info
(
"
==========================>hasWindowFocus=======================>
"
);
console
.
info
(
"
hasWindowFocus data:
"
+
JSON
.
stringify
(
data
)
);
});
```
...
...
@@ -399,11 +397,9 @@ getWant(callback: AsyncCallback\<Want>): void
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
getWant
(
(
err
,
data
)
=>
{
console
.
info
(
"
err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
))
}
)
featureAbility
.
getWant
((
err
,
data
)
=>
{
console
.
info
(
"
getWant err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
```
## featureAbility.getWant
...
...
@@ -425,7 +421,7 @@ getWant(): Promise\<Want>
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
getWant
().
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantCallBack=======================>
"
);
console
.
info
(
"
getWant data:
"
+
JSON
.
stringify
(
data
)
);
});
```
...
...
@@ -448,7 +444,9 @@ getContext(): Context
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
var
context
=
featureAbility
.
getContext
()
context
.
getBundleName
()
context
.
getBundleName
((
err
,
data
)
=>
{
console
.
info
(
"
getBundleName err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
));
});
```
## featureAbility.terminateSelf<sup>7+</sup>
...
...
@@ -495,7 +493,7 @@ terminateSelf(): Promise\<void>
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
featureAbility
.
terminateSelf
().
then
((
data
)
=>
{
console
.
info
(
"
==========================>terminateSelf
CallBack
=======================>
"
);
console
.
info
(
"
==========================>terminateSelf=======================>
"
);
});
```
...
...
@@ -535,8 +533,8 @@ ConnectOptions类型说明
**示例:**
```
javascript
import
rpc
from
'
@ohos.rpc
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
rpc
from
'
@ohos.rpc
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
function
onConnectCallback
(
element
,
remote
){
console
.
log
(
'
ConnectAbility onConnect remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
));
}
...
...
@@ -546,7 +544,7 @@ function onDisconnectCallback(element){
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
featureAbility
.
connectAbility
(
var
conn
ect
Id
=
featureAbility
.
connectAbility
(
{
deviceId
:
""
,
bundleName
:
"
com.ix.ServiceAbility
"
,
...
...
@@ -578,8 +576,8 @@ disconnectAbility(connection: number, callback:AsyncCallback\<void>): void
**示例:**
```
javascript
import
rpc
from
'
@ohos.rpc
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
rpc
from
'
@ohos.rpc
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
function
onConnectCallback
(
element
,
remote
){
console
.
log
(
'
ConnectAbility onConnect remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
));
}
...
...
@@ -589,7 +587,7 @@ function onDisconnectCallback(element){
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
featureAbility
.
connectAbility
(
var
conn
ect
Id
=
featureAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
...
...
@@ -600,7 +598,7 @@ var connId = featureAbility.connectAbility(
onFailed
:
onFailedCallback
,
},
);
var
result
=
featureAbility
.
disconnectAbility
(
connId
,
var
result
=
featureAbility
.
disconnectAbility
(
conn
ect
Id
,
(
error
)
=>
{
console
.
log
(
'
featureAbilityTest DisConnectJsSameBundleName result errCode :
'
+
error
.
code
)
},
...
...
@@ -630,8 +628,8 @@ disconnectAbility(connection: number): Promise\<void>
**示例:**
```
javascript
import
rpc
from
'
@ohos.rpc
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
rpc
from
'
@ohos.rpc
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
function
onConnectCallback
(
element
,
remote
){
console
.
log
(
'
ConnectAbility onConnect remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
));
}
...
...
@@ -641,7 +639,7 @@ function onDisconnectCallback(element){
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
featureAbility
.
connectAbility
(
var
conn
ect
Id
=
featureAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
...
...
@@ -653,7 +651,7 @@ var connId = featureAbility.connectAbility(
},
);
featureAbility
.
disconnectAbility
(
connId
).
then
((
data
)
=>
{
featureAbility
.
disconnectAbility
(
conn
ect
Id
).
then
((
data
)
=>
{
console
.
log
(
'
data :
'
+
data
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
featureAbilityTest result errCode :
'
+
error
.
code
);
...
...
@@ -678,11 +676,9 @@ getWindow(callback: AsyncCallback\<window.Window>): void
**示例:**
```
javascript
featureAbility
.
getWindow
(
(
err
,
data
)
=>
{
console
.
info
(
"
err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
JSON
.
stringify
(
data
))
}
)
featureAbility
.
getWindow
((
err
,
data
)
=>
{
console
.
info
(
"
getWindow err:
"
+
JSON
.
stringify
(
err
)
+
"
data:
"
+
typeof
(
data
));
});
```
## featureAbility.getWindow<sup>7+</sup>
...
...
@@ -703,7 +699,7 @@ getWindow(): Promise\<window.Window>;
```
javascript
featureAbility
.
getWindow
().
then
((
data
)
=>
{
console
.
info
(
"
=============getWindowPromise==========
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
getWindow data:
"
+
typeof
(
data
));
});
```
...
...
@@ -725,8 +721,8 @@ onConnect(elementName: ElementName, remote: rpc.IRemoteObject): void;
**示例:**
```
javascript
import
rpc
from
'
@ohos.rpc
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
rpc
from
'
@ohos.rpc
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
function
onConnectCallback
(
element
,
remote
){
console
.
log
(
'
ConnectAbility onConnect remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
));
}
...
...
@@ -736,7 +732,7 @@ function onDisconnectCallback(element){
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
featureAbility
.
connectAbility
(
var
conn
ect
Id
=
featureAbility
.
connectAbility
(
{
deviceId
:
""
,
bundleName
:
"
com.ix.ServiceAbility
"
,
...
...
@@ -767,8 +763,8 @@ onDisconnect(elementName: ElementName): void;
**示例:**
```
javascript
import
rpc
from
'
@ohos.rpc
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
rpc
from
'
@ohos.rpc
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
function
onConnectCallback
(
element
,
remote
){
console
.
log
(
'
ConnectAbility onConnect remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
));
}
...
...
@@ -778,7 +774,7 @@ function onDisconnectCallback(element){
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
featureAbility
.
connectAbility
(
var
conn
ect
Id
=
featureAbility
.
connectAbility
(
{
deviceId
:
""
,
bundleName
:
"
com.ix.ServiceAbility
"
,
...
...
@@ -809,8 +805,8 @@ ConnectAbility调用失败时的回调函数。
**示例:**
```
javascript
import
rpc
from
'
@ohos.rpc
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
rpc
from
'
@ohos.rpc
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
function
onConnectCallback
(
element
,
remote
){
console
.
log
(
'
ConnectAbility onConnect remote is proxy:
'
+
(
remote
instanceof
rpc
.
RemoteProxy
));
}
...
...
@@ -820,7 +816,7 @@ function onDisconnectCallback(element){
function
onFailedCallback
(
code
){
console
.
log
(
'
featureAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
featureAbility
.
connectAbility
(
var
conn
ect
Id
=
featureAbility
.
connectAbility
(
{
deviceId
:
""
,
bundleName
:
"
com.ix.ServiceAbility
"
,
...
...
zh-cn/application-dev/reference/apis/js-apis-particleAbility.md
浏览文件 @
2aef369a
...
...
@@ -415,7 +415,7 @@ connectAbility(request: Want, options:ConnectOptions): number
function
onFailedCallback
(
code
){
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
particleAbility
.
connectAbility
(
var
conn
ect
Id
=
particleAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
...
...
@@ -427,7 +427,7 @@ connectAbility(request: Want, options:ConnectOptions): number
},
);
particleAbility
.
disconnectAbility
(
connId
).
then
((
data
)
=>
{
particleAbility
.
disconnectAbility
(
conn
ect
Id
).
then
((
data
)
=>
{
console
.
log
(
"
data:
"
+
data
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
particleAbilityTest result errCode :
'
+
error
.
code
)
...
...
@@ -464,7 +464,7 @@ import rpc from '@ohos.rpc'
function
onFailedCallback
(
code
){
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
particleAbility
.
connectAbility
(
var
conn
ect
Id
=
particleAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
...
...
@@ -475,7 +475,7 @@ import rpc from '@ohos.rpc'
onFailed
:
onFailedCallback
,
},
);
var
result
=
particleAbility
.
disconnectAbility
(
connId
).
then
((
data
)
=>
{
var
result
=
particleAbility
.
disconnectAbility
(
conn
ect
Id
).
then
((
data
)
=>
{
console
.
log
(
"
data:
"
+
data
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
particleAbilityTest result errCode :
'
+
error
.
code
)
...
...
@@ -511,7 +511,7 @@ function onConnectCallback(element, remote){
function
onFailedCallback
(
code
){
console
.
log
(
'
particleAbilityTest ConnectAbility onFailed errCode :
'
+
code
)
}
var
connId
=
particleAbility
.
connectAbility
(
var
conn
ect
Id
=
particleAbility
.
connectAbility
(
{
bundleName
:
"
com.ix.ServiceAbility
"
,
abilityName
:
"
ServiceAbilityA
"
,
...
...
@@ -523,7 +523,7 @@ function onConnectCallback(element, remote){
},
);
particleAbility
.
disconnectAbility
(
connId
).
then
((
data
)
=>
{
particleAbility
.
disconnectAbility
(
conn
ect
Id
).
then
((
data
)
=>
{
console
.
log
(
"
data:
"
+
data
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
particleAbilityTest result errCode :
'
+
error
.
code
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录