Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
c9f2beec
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
未验证
提交
c9f2beec
编写于
1月 04, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 04, 2023
浏览文件
操作
浏览文件
下载
差异文件
!12949 wantagent文档修改
Merge pull request !12949 from zhuhan/wantagent
上级
373b7151
6f2767cd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
437 addition
and
581 deletion
+437
-581
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
...ation-dev/reference/apis/js-apis-app-ability-wantAgent.md
+242
-243
zh-cn/application-dev/reference/apis/js-apis-wantAgent.md
zh-cn/application-dev/reference/apis/js-apis-wantAgent.md
+195
-338
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
浏览文件 @
c9f2beec
...
@@ -24,10 +24,11 @@ getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void
...
@@ -24,10 +24,11 @@ getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ----------------------- |
| -------- | -------------------------- | ---- | ----------------------- |
| info |
WantAgentInfo
| 是 | WantAgent信息。 |
| info |
[
WantAgentInfo
](
js-apis-inner-wantAgent-wantAgentInfo.md
)
| 是 | WantAgent信息。 |
| callback | AsyncCallback
\<
WantAgent
\>
| 是 | 创建WantAgent的回调方法。 |
| callback | AsyncCallback
\<
WantAgent
\>
| 是 | 创建WantAgent的回调方法。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -52,33 +53,31 @@ getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void
...
@@ -52,33 +53,31 @@ getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -90,15 +89,15 @@ var wantAgentInfo = {
...
@@ -90,15 +89,15 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
err
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -126,6 +125,7 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
...
@@ -126,6 +125,7 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
| Promise
\<
WantAgent
\>
| 以Promise形式返回WantAgent。 |
| Promise
\<
WantAgent
\>
| 以Promise形式返回WantAgent。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -150,30 +150,29 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
...
@@ -150,30 +150,29 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -212,6 +211,7 @@ getBundleName(agent: WantAgent, callback: AsyncCallback\<string\>): void
...
@@ -212,6 +211,7 @@ getBundleName(agent: WantAgent, callback: AsyncCallback\<string\>): void
| callback | AsyncCallback
\<
string
\>
| 是 | 获取WantAgent实例的包名的回调方法。 |
| callback | AsyncCallback
\<
string
\>
| 是 | 获取WantAgent实例的包名的回调方法。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -241,26 +241,26 @@ getBundleName(agent: WantAgent, callback: AsyncCallback\<string\>): void
...
@@ -241,26 +241,26 @@ getBundleName(agent: WantAgent, callback: AsyncCallback\<string\>): void
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -272,7 +272,7 @@ var wantAgentInfo = {
...
@@ -272,7 +272,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
wantAgent
));
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
wantAgent
));
...
@@ -291,9 +291,9 @@ function getWantAgentCallback(err, data) {
...
@@ -291,9 +291,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
getBundleName failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getBundleName failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -321,6 +321,7 @@ getBundleName(agent: WantAgent): Promise\<string\>
...
@@ -321,6 +321,7 @@ getBundleName(agent: WantAgent): Promise\<string\>
| Promise
\<
string
\>
| 以Promise形式返回获取WantAgent实例的包名。 |
| Promise
\<
string
\>
| 以Promise形式返回获取WantAgent实例的包名。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -345,32 +346,31 @@ getBundleName(agent: WantAgent): Promise\<string\>
...
@@ -345,32 +346,31 @@ getBundleName(agent: WantAgent): Promise\<string\>
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -382,7 +382,7 @@ var wantAgentInfo = {
...
@@ -382,7 +382,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
wantAgent
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
wantAgent
));
...
@@ -397,9 +397,9 @@ function getWantAgentCallback(err, data) {
...
@@ -397,9 +397,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
getBundleName failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getBundleName failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -422,6 +422,7 @@ getUid(agent: WantAgent, callback: AsyncCallback\<number\>): void
...
@@ -422,6 +422,7 @@ getUid(agent: WantAgent, callback: AsyncCallback\<number\>): void
| callback | AsyncCallback
\<
number
\>
| 是 | 获取WantAgent实例的用户ID的回调方法。 |
| callback | AsyncCallback
\<
number
\>
| 是 | 获取WantAgent实例的用户ID的回调方法。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -446,33 +447,32 @@ getUid(agent: WantAgent, callback: AsyncCallback\<number\>): void
...
@@ -446,33 +447,32 @@ getUid(agent: WantAgent, callback: AsyncCallback\<number\>): void
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
import
WantAgent
from
'
@ohos.app.ability.wantAgent
'
;
import
WantAgent
from
'
@ohos.app.ability.wantAgent
'
;
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -484,7 +484,7 @@ var wantAgentInfo = {
...
@@ -484,7 +484,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
err
));
...
@@ -503,9 +503,9 @@ function getWantAgentCallback(err, data) {
...
@@ -503,9 +503,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
getUid failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getUid failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -533,6 +533,7 @@ getUid(agent: WantAgent): Promise\<number\>
...
@@ -533,6 +533,7 @@ getUid(agent: WantAgent): Promise\<number\>
| Promise
\<
number
\>
| 以Promise形式返回获取WantAgent实例的用户ID。 |
| Promise
\<
number
\>
| 以Promise形式返回获取WantAgent实例的用户ID。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -557,32 +558,31 @@ getUid(agent: WantAgent): Promise\<number\>
...
@@ -557,32 +558,31 @@ getUid(agent: WantAgent): Promise\<number\>
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -594,7 +594,7 @@ var wantAgentInfo = {
...
@@ -594,7 +594,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
wantAgent
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
wantAgent
));
...
@@ -609,9 +609,9 @@ function getWantAgentCallback(err, data) {
...
@@ -609,9 +609,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
getUid failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getUid failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -635,7 +635,7 @@ getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void
...
@@ -635,7 +635,7 @@ getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void
| callback | AsyncCallback
\<
[
Want
](
js-apis-app-ability-want.md
)
\>
| 是 | 获取WantAgent对象want的回调方法。 |
| callback | AsyncCallback
\<
[
Want
](
js-apis-app-ability-want.md
)
\>
| 是 | 获取WantAgent对象want的回调方法。 |
**错误码:**
**错误码:**
|错误码ID |错误信息 |
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -660,32 +660,31 @@ getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void
...
@@ -660,32 +660,31 @@ getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -697,7 +696,7 @@ var wantAgentInfo = {
...
@@ -697,7 +696,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
wantAgent
));
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
wantAgent
));
...
@@ -716,9 +715,9 @@ function getWantAgentCallback(err, data) {
...
@@ -716,9 +715,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
getWant failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWant failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -748,6 +747,7 @@ getWant(agent: WantAgent): Promise\<Want\>
...
@@ -748,6 +747,7 @@ getWant(agent: WantAgent): Promise\<Want\>
| Promise
\<
Want
\>
| 以Promise形式返回获取WantAgent对象的want。 |
| Promise
\<
Want
\>
| 以Promise形式返回获取WantAgent对象的want。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -772,32 +772,31 @@ getWant(agent: WantAgent): Promise\<Want\>
...
@@ -772,32 +772,31 @@ getWant(agent: WantAgent): Promise\<Want\>
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -809,7 +808,7 @@ var wantAgentInfo = {
...
@@ -809,7 +808,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
wantAgent
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
wantAgent
));
...
@@ -824,9 +823,9 @@ function getWantAgentCallback(err, data) {
...
@@ -824,9 +823,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
getUid failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getUid failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -849,6 +848,7 @@ cancel(agent: WantAgent, callback: AsyncCallback\<void\>): void
...
@@ -849,6 +848,7 @@ cancel(agent: WantAgent, callback: AsyncCallback\<void\>): void
| callback | AsyncCallback
\<
void
\>
| 是 | 取消WantAgent实例的回调方法。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 取消WantAgent实例的回调方法。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -873,32 +873,31 @@ cancel(agent: WantAgent, callback: AsyncCallback\<void\>): void
...
@@ -873,32 +873,31 @@ cancel(agent: WantAgent, callback: AsyncCallback\<void\>): void
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -910,7 +909,7 @@ var wantAgentInfo = {
...
@@ -910,7 +909,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
wantAgent
));
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
wantAgent
));
...
@@ -929,9 +928,9 @@ function getWantAgentCallback(err, data) {
...
@@ -929,9 +928,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
cancel failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
cancel failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -959,6 +958,7 @@ cancel(agent: WantAgent): Promise\<void\>
...
@@ -959,6 +958,7 @@ cancel(agent: WantAgent): Promise\<void\>
| Promise
\<
void
\>
| 以Promise形式获取异步返回结果。 |
| Promise
\<
void
\>
| 以Promise形式获取异步返回结果。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -983,32 +983,31 @@ cancel(agent: WantAgent): Promise\<void\>
...
@@ -983,32 +983,31 @@ cancel(agent: WantAgent): Promise\<void\>
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -1020,7 +1019,7 @@ var wantAgentInfo = {
...
@@ -1020,7 +1019,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
wantAgent
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
wantAgent
));
...
@@ -1035,9 +1034,9 @@ function getWantAgentCallback(err, data) {
...
@@ -1035,9 +1034,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
cancel failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
cancel failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -1059,6 +1058,7 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\<Co
...
@@ -1059,6 +1058,7 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\<Co
| callback | AsyncCallback
\<
[
CompleteData
](
#completedata
)
\>
| 否 | 主动激发WantAgent实例的回调方法。 |
| callback | AsyncCallback
\<
[
CompleteData
](
#completedata
)
\>
| 否 | 主动激发WantAgent实例的回调方法。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -1083,36 +1083,35 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\<Co
...
@@ -1083,36 +1083,35 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\<Co
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
// triggerInfo
// triggerInfo
var
triggerInfo
=
{
let
triggerInfo
=
{
code
:
0
//自定义义结果码
code
:
0
//自定义义结果码
}
}
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -1124,7 +1123,7 @@ var wantAgentInfo = {
...
@@ -1124,7 +1123,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
wantAgent
));
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
wantAgent
));
...
@@ -1143,9 +1142,9 @@ function getWantAgentCallback(err, data) {
...
@@ -1143,9 +1142,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
getUid failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getUid failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -1156,7 +1155,7 @@ try{
...
@@ -1156,7 +1155,7 @@ try{
equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback
\<
boolean
\>
): void
equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback
\<
boolean
\>
): void
判断两个WantAgent实例是否相等(
callback形式)
。
判断两个WantAgent实例是否相等(
Callback形式),以此来判断是否是来自同一应用的相同操作
。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
@@ -1169,6 +1168,7 @@ equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback\<boolean\
...
@@ -1169,6 +1168,7 @@ equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback\<boolean\
| callback | AsyncCallback
\<
boolean
\>
| 是 | 判断两个WantAgent实例是否相等的回调方法。 |
| callback | AsyncCallback
\<
boolean
\>
| 是 | 判断两个WantAgent实例是否相等的回调方法。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -1193,33 +1193,32 @@ equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback\<boolean\
...
@@ -1193,33 +1193,32 @@ equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback\<boolean\
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent1
;
let
wantAgent1
;
var
wantAgent2
;
let
wantAgent2
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -1231,7 +1230,7 @@ var wantAgentInfo = {
...
@@ -1231,7 +1230,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent1
=
data
;
wantAgent1
=
data
;
wantAgent2
=
data
;
wantAgent2
=
data
;
}
else
{
}
else
{
...
@@ -1251,9 +1250,9 @@ function getWantAgentCallback(err, data) {
...
@@ -1251,9 +1250,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
equal failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
equal failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -1264,7 +1263,7 @@ try{
...
@@ -1264,7 +1263,7 @@ try{
equal(agent: WantAgent, otherAgent: WantAgent): Promise
\<
boolean
\>
equal(agent: WantAgent, otherAgent: WantAgent): Promise
\<
boolean
\>
判断两个WantAgent实例是否相等(Promise形式)。
判断两个WantAgent实例是否相等(Promise形式)
,以此来判断是否是来自同一应用的相同操作
。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
@@ -1282,6 +1281,7 @@ equal(agent: WantAgent, otherAgent: WantAgent): Promise\<boolean\>
...
@@ -1282,6 +1281,7 @@ equal(agent: WantAgent, otherAgent: WantAgent): Promise\<boolean\>
| Promise
\<
boolean
\>
| 以Promise形式返回获取判断两个WantAgent实例是否相等的结果。 |
| Promise
\<
boolean
\>
| 以Promise形式返回获取判断两个WantAgent实例是否相等的结果。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -1306,33 +1306,32 @@ equal(agent: WantAgent, otherAgent: WantAgent): Promise\<boolean\>
...
@@ -1306,33 +1306,32 @@ equal(agent: WantAgent, otherAgent: WantAgent): Promise\<boolean\>
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent1
;
let
wantAgent1
;
var
wantAgent2
;
let
wantAgent2
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -1344,7 +1343,7 @@ var wantAgentInfo = {
...
@@ -1344,7 +1343,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent1
=
data
;
wantAgent1
=
data
;
wantAgent2
=
data
;
wantAgent2
=
data
;
}
else
{
}
else
{
...
@@ -1360,9 +1359,9 @@ function getWantAgentCallback(err, data) {
...
@@ -1360,9 +1359,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
equal failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
equal failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -1383,6 +1382,7 @@ getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
...
@@ -1383,6 +1382,7 @@ getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
| callback | AsyncCallback
\<
number> | 是 | 获取一个WantAgent的OperationType信息的回调方法。 |
| callback | AsyncCallback
\<
number> | 是 | 获取一个WantAgent的OperationType信息的回调方法。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -1407,32 +1407,31 @@ getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
...
@@ -1407,32 +1407,31 @@ getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -1444,7 +1443,7 @@ var wantAgentInfo = {
...
@@ -1444,7 +1443,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
wantAgent
));
console
.
info
(
'
getWantAgent failed
'
+
JSON
.
stringify
(
wantAgent
));
...
@@ -1463,9 +1462,9 @@ function getWantAgentCallback(err, data) {
...
@@ -1463,9 +1462,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
getOperationTypeCallback failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getOperationTypeCallback failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
@@ -1491,6 +1490,7 @@ getOperationType(agent: WantAgent): Promise\<number>;
...
@@ -1491,6 +1490,7 @@ getOperationType(agent: WantAgent): Promise\<number>;
| Promise
\<
number> | 以Promise形式返回获取operationType的结果。 |
| Promise
\<
number> | 以Promise形式返回获取operationType的结果。 |
**错误码:**
**错误码:**
错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
|-----------|--------------------|
|-----------|--------------------|
| 16000001 | Input error. The specified ability name does not exist. |
| 16000001 | Input error. The specified ability name does not exist. |
...
@@ -1515,32 +1515,31 @@ getOperationType(agent: WantAgent): Promise\<number>;
...
@@ -1515,32 +1515,31 @@ getOperationType(agent: WantAgent): Promise\<number>;
| 16000151 | Invalid wantagent object.|
| 16000151 | Invalid wantagent object.|
| 16000152 | wantAgent object not found.|
| 16000152 | wantAgent object not found.|
| 16000153 | wangAgent object canceled.|
| 16000153 | wangAgent object canceled.|
以上错误码详细介绍请参考
[
errcode-ability
](
../errorcodes/errorcode-ability.md
)
**示例:**
**示例:**
```
ts
```
ts
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -1552,7 +1551,7 @@ var wantAgentInfo = {
...
@@ -1552,7 +1551,7 @@ var wantAgentInfo = {
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
if
(
err
==
undefined
)
{
if
(
err
==
=
undefined
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
wantAgent
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
wantAgent
));
...
@@ -1567,9 +1566,9 @@ function getWantAgentCallback(err, data) {
...
@@ -1567,9 +1566,9 @@ function getWantAgentCallback(err, data) {
console
.
info
(
'
getOperationType failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getOperationType failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
}
}
try
{
try
{
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
);
}
catch
(
err
){
}
catch
(
err
)
{
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
console
.
info
(
'
getWantAgent failed!
'
+
JSON
.
stringify
(
err
.
code
)
+
JSON
.
stringify
(
err
.
message
));
}
}
```
```
...
...
zh-cn/application-dev/reference/apis/js-apis-wantAgent.md
浏览文件 @
c9f2beec
...
@@ -24,7 +24,7 @@ getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void
...
@@ -24,7 +24,7 @@ getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ----------------------- |
| -------- | -------------------------- | ---- | ----------------------- |
| info |
WantAgentInfo
| 是 | WantAgent信息。 |
| info |
[
WantAgentInfo
](
js-apis-inner-wantAgent-wantAgentInfo.md
)
| 是 | WantAgent信息。 |
| callback | AsyncCallback
\<
WantAgent
\>
| 是 | 创建WantAgent的回调方法。 |
| callback | AsyncCallback
\<
WantAgent
\>
| 是 | 创建WantAgent的回调方法。 |
**示例:**
**示例:**
...
@@ -34,27 +34,31 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -34,27 +34,31 @@ import WantAgent from '@ohos.wantAgent';
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
if
(
err
.
code
)
{
console
.
info
(
'
getWantAgent Callback err:
'
+
JSON
.
stringify
(
err
))
}
else
{
console
.
info
(
'
getWantAgent Callback success
'
)
}
}
}
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -64,7 +68,7 @@ var wantAgentInfo = {
...
@@ -64,7 +68,7 @@ var wantAgentInfo = {
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
}
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
;
```
```
...
@@ -81,7 +85,7 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
...
@@ -81,7 +85,7 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------------- | ---- | ------------- |
| ---- | ------------- | ---- | ------------- |
| info |
WantAgentInfo
| 是 | WantAgent信息。 |
| info |
[
WantAgentInfo
](
js-apis-inner-wantAgent-wantAgentInfo.md
)
| 是 | WantAgent信息。 |
**返回值:**
**返回值:**
...
@@ -96,24 +100,24 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -96,24 +100,24 @@ import WantAgent from '@ohos.wantAgent';
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -124,7 +128,7 @@ var wantAgentInfo = {
...
@@ -124,7 +128,7 @@ var wantAgentInfo = {
}
}
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
});
});
```
```
...
@@ -152,11 +156,11 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -152,11 +156,11 @@ import WantAgent from '@ohos.wantAgent';
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
if
(
err
.
code
==
0
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
...
@@ -164,24 +168,24 @@ function getWantAgentCallback(err, data) {
...
@@ -164,24 +168,24 @@ function getWantAgentCallback(err, data) {
}
}
}
}
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -195,9 +199,9 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...
@@ -195,9 +199,9 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
//getBundleName回调
//getBundleName回调
function
getBundleNameCallback
(
err
,
data
)
{
function
getBundleNameCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getBundleNameCallback=======================>
"
);
console
.
info
(
'
==========================>getBundleNameCallback=======================>
'
);
}
}
WantAgent
.
getBundleName
(
wantAgent
,
getBundleNameCallback
)
WantAgent
.
getBundleName
(
wantAgent
,
getBundleNameCallback
)
;
```
```
...
@@ -228,27 +232,27 @@ getBundleName(agent: WantAgent): Promise\<string\>
...
@@ -228,27 +232,27 @@ getBundleName(agent: WantAgent): Promise\<string\>
import
WantAgent
from
'
@ohos.wantAgent
'
;
import
WantAgent
from
'
@ohos.wantAgent
'
;
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -259,12 +263,12 @@ var wantAgentInfo = {
...
@@ -259,12 +263,12 @@ var wantAgentInfo = {
}
}
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
wantAgent
=
data
;
});
});
WantAgent
.
getBundleName
(
wantAgent
).
then
((
data
)
=>
{
WantAgent
.
getBundleName
(
wantAgent
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getBundleNameCallback=======================>
"
);
console
.
info
(
'
==========================>getBundleNameCallback=======================>
'
);
});
});
```
```
...
@@ -292,11 +296,11 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -292,11 +296,11 @@ import WantAgent from '@ohos.wantAgent';
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
if
(
err
.
code
==
0
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
...
@@ -304,24 +308,24 @@ function getWantAgentCallback(err, data) {
...
@@ -304,24 +308,24 @@ function getWantAgentCallback(err, data) {
}
}
}
}
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -335,9 +339,9 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...
@@ -335,9 +339,9 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
//getUid回调
//getUid回调
function
getUidCallback
(
err
,
data
)
{
function
getUidCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getUidCallback=======================>
"
);
console
.
info
(
'
==========================>getUidCallback=======================>
'
);
}
}
WantAgent
.
getUid
(
wantAgent
,
getUidCallback
)
WantAgent
.
getUid
(
wantAgent
,
getUidCallback
)
;
```
```
...
@@ -369,27 +373,27 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -369,27 +373,27 @@ import WantAgent from '@ohos.wantAgent';
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -400,162 +404,16 @@ var wantAgentInfo = {
...
@@ -400,162 +404,16 @@ var wantAgentInfo = {
}
}
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
wantAgent
=
data
;
});
});
WantAgent
.
getUid
(
wantAgent
).
then
((
data
)
=>
{
WantAgent
.
getUid
(
wantAgent
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getUidCallback=======================>
"
);
console
.
info
(
'
==========================>getUidCallback=======================>
'
);
});
});
```
```
## WantAgent.getWant
getWant(agent: WantAgent, callback: AsyncCallback
\<
Want
\>
): void
获取WantAgent对象的want(callback形式)。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------------- |
| agent | WantAgent | 是 | WantAgent对象。 |
| callback | AsyncCallback
\<
Want
\>
| 是 | 获取WantAgent对象want的回调方法。 |
**示例:**
```
ts
import
WantAgent
from
'
@ohos.wantAgent
'
;
//wantAgent对象
var
wantAgent
;
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
if
(
err
.
code
==
0
)
{
wantAgent
=
data
;
}
else
{
console
.
info
(
'
----getWantAgent failed!----
'
);
}
}
//WantAgentInfo对象
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey6
:
true
,
}
}
],
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
WantAgent
.
getWantAgent
(
wantAgentInfo
,
getWantAgentCallback
)
//getWant回调
function
getWantCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantCallback=======================>
"
);
}
WantAgent
.
getWant
(
wantAgent
,
getWantCallback
)
```
## WantAgent.getWant
getWant(agent: WantAgent): Promise
\<
Want
\>
获取WantAgent对象的want(Promise形式)。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统API**
: 此接口为系统接口,三方应用不支持调用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | --------- | ---- | ------------- |
| agent | WantAgent | 是 | WantAgent对象。 |
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise
\<
Want
\>
| 以Promise形式返回获取WantAgent对象的want。 |
**示例:**
```
ts
import
WantAgent
from
'
@ohos.wantAgent
'
;
//wantAgent对象
var
wantAgent
;
//WantAgentInfo对象
var
wantAgentInfo
=
{
wants
:
[
{
deviceId
:
"
deviceId
"
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
abilityName
:
"
com.example.test.MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
parameters
:
{
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey6
:
true
,
}
}
],
operationType
:
WantAgent
.
OperationType
.
START_ABILITIES
,
requestCode
:
0
,
wantAgentFlags
:[
WantAgent
.
WantAgentFlags
.
UPDATE_PRESENT_FLAG
]
}
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
wantAgent
=
data
;
});
WantAgent
.
getWant
(
wantAgent
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantCallback=======================>
"
);
});
```
## WantAgent.cancel
## WantAgent.cancel
cancel(agent: WantAgent, callback: AsyncCallback
\<
void
\>
): void
cancel(agent: WantAgent, callback: AsyncCallback
\<
void
\>
): void
...
@@ -578,11 +436,11 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -578,11 +436,11 @@ import WantAgent from '@ohos.wantAgent';
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
if
(
err
.
code
==
0
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
...
@@ -590,24 +448,24 @@ function getWantAgentCallback(err, data) {
...
@@ -590,24 +448,24 @@ function getWantAgentCallback(err, data) {
}
}
}
}
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -621,9 +479,9 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...
@@ -621,9 +479,9 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
//cancel回调
//cancel回调
function
cancelCallback
(
err
,
data
)
{
function
cancelCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>cancelCallback=======================>
"
);
console
.
info
(
'
==========================>cancelCallback=======================>
'
);
}
}
WantAgent
.
cancel
(
wantAgent
,
cancelCallback
)
WantAgent
.
cancel
(
wantAgent
,
cancelCallback
)
;
```
```
...
@@ -655,27 +513,27 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -655,27 +513,27 @@ import WantAgent from '@ohos.wantAgent';
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -686,12 +544,12 @@ var wantAgentInfo = {
...
@@ -686,12 +544,12 @@ var wantAgentInfo = {
}
}
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
wantAgent
=
data
;
});
});
WantAgent
.
cancel
(
wantAgent
).
then
((
data
)
=>
{
WantAgent
.
cancel
(
wantAgent
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>cancelCallback=======================>
"
);
console
.
info
(
'
==========================>cancelCallback=======================>
'
);
});
});
```
```
...
@@ -720,11 +578,11 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -720,11 +578,11 @@ import WantAgent from '@ohos.wantAgent';
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
if
(
err
.
code
==
0
)
{
wantAgent
=
data
;
wantAgent
=
data
;
}
else
{
}
else
{
...
@@ -732,24 +590,24 @@ function getWantAgentCallback(err, data) {
...
@@ -732,24 +590,24 @@ function getWantAgentCallback(err, data) {
}
}
}
}
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -763,7 +621,7 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...
@@ -763,7 +621,7 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
//trigger回调
//trigger回调
function
triggerCallback
(
data
)
{
function
triggerCallback
(
data
)
{
console
.
info
(
"
==========================>triggerCallback=======================>
"
);
console
.
info
(
'
==========================>triggerCallback=======================>
'
);
}
}
var
triggerInfo
=
{
var
triggerInfo
=
{
...
@@ -778,7 +636,7 @@ WantAgent.trigger(wantAgent, triggerInfo, triggerCallback)
...
@@ -778,7 +636,7 @@ WantAgent.trigger(wantAgent, triggerInfo, triggerCallback)
equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback
\<
boolean
\>
): void
equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback
\<
boolean
\>
): void
判断两个WantAgent实例是否相等(callback形式)。
判断两个WantAgent实例是否相等(callback形式)
,以此来判断是否是来自同一应用的相同操作
。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
@@ -797,12 +655,12 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -797,12 +655,12 @@ import WantAgent from '@ohos.wantAgent';
//wantAgent对象
//wantAgent对象
var
wantAgent1
;
let
wantAgent1
;
var
wantAgent2
;
let
wantAgent2
;
//getWantAgent回调
//getWantAgent回调
function
getWantAgentCallback
(
err
,
data
)
{
function
getWantAgentCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
if
(
err
.
code
==
0
)
{
if
(
err
.
code
==
0
)
{
wantAgent1
=
data
;
wantAgent1
=
data
;
wantAgent2
=
data
;
wantAgent2
=
data
;
...
@@ -811,24 +669,24 @@ function getWantAgentCallback(err, data) {
...
@@ -811,24 +669,24 @@ function getWantAgentCallback(err, data) {
}
}
}
}
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -842,7 +700,7 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
...
@@ -842,7 +700,7 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
//equal回调
//equal回调
function
equalCallback
(
err
,
data
)
{
function
equalCallback
(
err
,
data
)
{
console
.
info
(
"
==========================>equalCallback=======================>
"
);
console
.
info
(
'
==========================>equalCallback=======================>
'
);
}
}
WantAgent
.
equal
(
wantAgent1
,
wantAgent2
,
equalCallback
)
WantAgent
.
equal
(
wantAgent1
,
wantAgent2
,
equalCallback
)
```
```
...
@@ -853,7 +711,7 @@ WantAgent.equal(wantAgent1, wantAgent2, equalCallback)
...
@@ -853,7 +711,7 @@ WantAgent.equal(wantAgent1, wantAgent2, equalCallback)
equal(agent: WantAgent, otherAgent: WantAgent): Promise
\<
boolean
\>
equal(agent: WantAgent, otherAgent: WantAgent): Promise
\<
boolean
\>
判断两个WantAgent实例是否相等(Promise形式)。
判断两个WantAgent实例是否相等(Promise形式)
,以此来判断是否是来自同一应用的相同操作
。
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
**系统能力**
:SystemCapability.Ability.AbilityRuntime.Core
...
@@ -877,28 +735,28 @@ import WantAgent from '@ohos.wantAgent';
...
@@ -877,28 +735,28 @@ import WantAgent from '@ohos.wantAgent';
//wantAgent对象
//wantAgent对象
var
wantAgent1
;
let
wantAgent1
;
var
wantAgent2
;
let
wantAgent2
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -909,13 +767,13 @@ var wantAgentInfo = {
...
@@ -909,13 +767,13 @@ var wantAgentInfo = {
}
}
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent1
=
data
;
wantAgent1
=
data
;
wantAgent2
=
data
;
wantAgent2
=
data
;
});
});
WantAgent
.
equal
(
wantAgent1
,
wantAgent2
).
then
((
data
)
=>
{
WantAgent
.
equal
(
wantAgent1
,
wantAgent2
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>equalCallback=======================>
"
);
console
.
info
(
'
==========================>equalCallback=======================>
'
);
});
});
```
```
...
@@ -940,27 +798,27 @@ getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
...
@@ -940,27 +798,27 @@ getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
import
WantAgent
from
'
@ohos.wantAgent
'
;
import
WantAgent
from
'
@ohos.wantAgent
'
;
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -971,7 +829,7 @@ var wantAgentInfo = {
...
@@ -971,7 +829,7 @@ var wantAgentInfo = {
}
}
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
wantAgent
=
data
;
});
});
...
@@ -1006,27 +864,27 @@ getOperationType(agent: WantAgent): Promise\<number>;
...
@@ -1006,27 +864,27 @@ getOperationType(agent: WantAgent): Promise\<number>;
import
WantAgent
from
'
@ohos.wantAgent
'
;
import
WantAgent
from
'
@ohos.wantAgent
'
;
//wantAgent对象
//wantAgent对象
var
wantAgent
;
let
wantAgent
;
//WantAgentInfo对象
//WantAgentInfo对象
var
wantAgentInfo
=
{
let
wantAgentInfo
=
{
wants
:
[
wants
:
[
{
{
deviceId
:
"
deviceId
"
,
deviceId
:
'
deviceId
'
,
bundleName
:
"
com.neu.setResultOnAbilityResultTest1
"
,
bundleName
:
'
com.neu.setResultOnAbilityResultTest1
'
,
abilityName
:
"
com.example.test.MainAbility
"
,
abilityName
:
'
com.example.test.MainAbility
'
,
action
:
"
action1
"
,
action
:
'
action1
'
,
entities
:
[
"
entity1
"
],
entities
:
[
'
entity1
'
],
type
:
"
MIMETYPE
"
,
type
:
'
MIMETYPE
'
,
uri
:
"
key={true,true,false}
"
,
uri
:
'
key={true,true,false}
'
,
parameters
:
parameters
:
{
{
mykey0
:
2222
,
mykey0
:
2222
,
mykey1
:
[
1
,
2
,
3
],
mykey1
:
[
1
,
2
,
3
],
mykey2
:
"
[1, 2, 3]
"
,
mykey2
:
'
[1, 2, 3]
'
,
mykey3
:
"
ssssssssssssssssssssssssss
"
,
mykey3
:
'
ssssssssssssssssssssssssss
'
,
mykey4
:
[
false
,
true
,
false
],
mykey4
:
[
false
,
true
,
false
],
mykey5
:
[
"
qqqqq
"
,
"
wwwwww
"
,
"
aaaaaaaaaaaaaaaaa
"
],
mykey5
:
[
'
qqqqq
'
,
'
wwwwww
'
,
'
aaaaaaaaaaaaaaaaa
'
],
mykey6
:
true
,
mykey6
:
true
,
}
}
}
}
...
@@ -1037,15 +895,14 @@ var wantAgentInfo = {
...
@@ -1037,15 +895,14 @@ var wantAgentInfo = {
}
}
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
WantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getWantAgentCallback=======================>
"
);
console
.
info
(
'
==========================>getWantAgentCallback=======================>
'
);
wantAgent
=
data
;
wantAgent
=
data
;
WantAgent
.
getOperationType
(
wantAgent
).
then
((
OperationType
)
=>
{
console
.
log
(
'
getOperationType success, OperationType:
'
+
OperationType
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
getOperationType fail, err:
'
+
err
);
})
});
});
WantAgent
.
getOperationType
(
wantAgent
).
then
((
OperationType
)
=>
{
console
.
log
(
'
getOperationType success, OperationType:
'
+
OperationType
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
getOperationType fail, err:
'
+
err
);
})
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录