• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# WantAgent
2
3>**NOTE**
4>
5>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
6
7## Modules to Import
8
9```js
10import WantAgent from '@ohos.wantAgent';
11```
12
13## WantAgent.getWantAgent
14
15getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void
16
17Obtains a **WantAgent** object. This API uses an asynchronous callback to return the result.
18
19**System capability**: SystemCapability.Ability.AbilityRuntime.Core
20
21**Parameters**
22
23| Name    | Readable| Writable | Type                      | Mandatory| Description                   |
24| -------- | --- | ---- | -------------------------- | ---- | ----------------------- |
25| info     | Yes  | No  | WantAgentInfo              | Yes  | Information about the **WantAgent** object to obtain.          |
26| callback | Yes  | No  | AsyncCallback\<WantAgent\> | Yes  | Callback used to return the **WantAgent** object.|
27
28**Example**
29
30```js
31import WantAgent from '@ohos.wantAgent';
32import { OperationType, WantAgentFlags } from '@ohos.wantagent';
33
34// getWantAgent callback
35function getWantAgentCallback(err, data) {
36	console.info("==========================>getWantAgentCallback=======================>");
37}
38// WantAgentInfo object
39var wantAgentInfo = {
40    wants: [
41        {
42            deviceId: "deviceId",
43            bundleName: "com.neu.setResultOnAbilityResultTest1",
44            abilityName: "com.example.test.MainAbility",
45            action: "action1",
46            entities: ["entity1"],
47            type: "MIMETYPE",
48            uri: "key={true,true,false}",
49            parameters:
50            {
51                mykey0: 2222,
52                mykey1: [1, 2, 3],
53                mykey2: "[1, 2, 3]",
54                mykey3: "ssssssssssssssssssssssssss",
55                mykey4: [false, true, false],
56                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
57                mykey6: true,
58            }
59        }
60    ],
61    operationType: OperationType.START_ABILITIES,
62    requestCode: 0,
63    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
64}
65
66WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
67```
68
69
70
71## WantAgent.getWantAgent
72
73getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
74
75Obtains a **WantAgent** object. This API uses a promise to return the result.
76
77**System capability**: SystemCapability.Ability.AbilityRuntime.Core
78
79**Parameters**
80
81| Name| Readable| Writable | Type         | Mandatory| Description         |
82| ---- | --- | ---- | ------------- | ---- | ------------- |
83| info | Yes  | No  | WantAgentInfo | Yes  | Information about the **WantAgent** object to obtain.|
84
85**Return value**
86
87| Type                                                       | Description                                                        |
88| ----------------------------------------------------------- | ------------------------------------------------------------ |
89| Promise\<WantAgent\> | Promise used to return the **WantAgent** object.|
90
91**Example**
92
93```js
94import WantAgent from '@ohos.wantAgent';
95import { OperationType, WantAgentFlags } from '@ohos.wantagent';
96
97// WantAgentInfo object
98var wantAgentInfo = {
99    wants: [
100        {
101            deviceId: "deviceId",
102            bundleName: "com.neu.setResultOnAbilityResultTest1",
103            abilityName: "com.example.test.MainAbility",
104            action: "action1",
105            entities: ["entity1"],
106            type: "MIMETYPE",
107            uri: "key={true,true,false}",
108            parameters:
109            {
110                mykey0: 2222,
111                mykey1: [1, 2, 3],
112                mykey2: "[1, 2, 3]",
113                mykey3: "ssssssssssssssssssssssssss",
114                mykey4: [false, true, false],
115                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
116                mykey6: true,
117            }
118        }
119    ],
120    operationType: OperationType.START_ABILITIES,
121    requestCode: 0,
122    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
123}
124
125WantAgent.getWantAgent(wantAgentInfo).then((data) => {
126	console.info("==========================>getWantAgentCallback=======================>");
127});
128```
129
130
131
132## WantAgent.getBundleName
133
134getBundleName(agent: WantAgent, callback: AsyncCallback\<string\>): void
135
136Obtains the bundle name of a **WantAgent** object. This API uses an asynchronous callback to return the result.
137
138**System capability**: SystemCapability.Ability.AbilityRuntime.Core
139
140**Parameters**
141
142| Name    | Readable| Writable | Type                   | Mandatory| Description                             |
143| -------- | --- | ---- | ----------------------- | ---- | --------------------------------- |
144| agent    | Yes  | No  | WantAgent               | Yes  | Target **WantAgent** object.                    |
145| callback | Yes  | No  | AsyncCallback\<string\> | Yes  | Callback used to return the bundle name.|
146
147**Example**
148
149```js
150import WantAgent from '@ohos.wantAgent';
151import { OperationType, WantAgentFlags } from '@ohos.wantagent';
152
153// WantAgent object
154var wantAgent;
155
156// getWantAgent callback
157function getWantAgentCallback(err, data) {
158	console.info("==========================>getWantAgentCallback=======================>");
159    if (err.code == 0) {
160    	wantAgent = data;
161    } else {
162        console.info('----getWantAgent failed!----');
163    }
164}
165// WantAgentInfo object
166var wantAgentInfo = {
167    wants: [
168        {
169            deviceId: "deviceId",
170            bundleName: "com.neu.setResultOnAbilityResultTest1",
171            abilityName: "com.example.test.MainAbility",
172            action: "action1",
173            entities: ["entity1"],
174            type: "MIMETYPE",
175            uri: "key={true,true,false}",
176            parameters:
177            {
178                mykey0: 2222,
179                mykey1: [1, 2, 3],
180                mykey2: "[1, 2, 3]",
181                mykey3: "ssssssssssssssssssssssssss",
182                mykey4: [false, true, false],
183                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
184                mykey6: true,
185            }
186        }
187    ],
188    operationType: OperationType.START_ABILITIES,
189    requestCode: 0,
190    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
191}
192
193WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
194
195// getBundleName callback
196function getBundleNameCallback(err, data) {
197	console.info("==========================>getBundleNameCallback=======================>");
198}
199WantAgent.getBundleName(wantAgent, getBundleNameCallback)
200```
201
202
203
204## WantAgent.getBundleName
205
206getBundleName(agent: WantAgent): Promise\<string\>
207
208Obtains the bundle name of a **WantAgent** object. This API uses a promise to return the result.
209
210**System capability**: SystemCapability.Ability.AbilityRuntime.Core
211
212**Parameters**
213
214| Name | Readable| Writable| Type     | Mandatory| Description         |
215| ----- | --- | ---- | --------- | ---- | ------------- |
216| agent | Yes  | No | WantAgent | Yes  | Target **WantAgent** object.|
217
218**Return value**
219
220| Type                                                       | Description                                                        |
221| ----------------------------------------------------------- | ------------------------------------------------------------ |
222| Promise\<string\> | Promise used to return the bundle name.|
223
224**Example**
225
226```js
227import WantAgent from '@ohos.wantAgent';
228import { OperationType, WantAgentFlags } from '@ohos.wantagent';
229
230// WantAgent object
231var wantAgent;
232
233// WantAgentInfo object
234var wantAgentInfo = {
235    wants: [
236        {
237            deviceId: "deviceId",
238            bundleName: "com.neu.setResultOnAbilityResultTest1",
239            abilityName: "com.example.test.MainAbility",
240            action: "action1",
241            entities: ["entity1"],
242            type: "MIMETYPE",
243            uri: "key={true,true,false}",
244            parameters:
245            {
246                mykey0: 2222,
247                mykey1: [1, 2, 3],
248                mykey2: "[1, 2, 3]",
249                mykey3: "ssssssssssssssssssssssssss",
250                mykey4: [false, true, false],
251                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
252                mykey6: true,
253            }
254        }
255    ],
256    operationType: OperationType.START_ABILITIES,
257    requestCode: 0,
258    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
259}
260
261WantAgent.getWantAgent(wantAgentInfo).then((data) => {
262	console.info("==========================>getWantAgentCallback=======================>");
263    wantAgent = data;
264});
265
266WantAgent.getBundleName(wantAgent).then((data) => {
267	console.info("==========================>getBundleNameCallback=======================>");
268});
269```
270
271
272
273## WantAgent.getUid
274
275getUid(agent: WantAgent, callback: AsyncCallback\<number\>): void
276
277Obtains the user ID of a **WantAgent** object. This API uses an asynchronous callback to return the result.
278
279**System capability**: SystemCapability.Ability.AbilityRuntime.Core
280
281**Parameters**
282
283| Name    | Readable| Writable| Type                   | Mandatory| Description                               |
284| -------- | --- | ---- | ----------------------- | ---- | ----------------------------------- |
285| agent    | Yes  | No | WantAgent               | Yes  | Target **WantAgent** object.                      |
286| callback | Yes  | No | AsyncCallback\<number\> | Yes  | Callback used to return the user ID.|
287
288**Example**
289
290```js
291import WantAgent from '@ohos.wantAgent';
292import { OperationType, WantAgentFlags } from '@ohos.wantagent';
293
294// WantAgent object
295var wantAgent;
296
297// getWantAgent callback
298function getWantAgentCallback(err, data) {
299	console.info("==========================>getWantAgentCallback=======================>");
300    if (err.code == 0) {
301    	wantAgent = data;
302    } else {
303        console.info('----getWantAgent failed!----');
304    }
305}
306// WantAgentInfo object
307var wantAgentInfo = {
308    wants: [
309        {
310            deviceId: "deviceId",
311            bundleName: "com.neu.setResultOnAbilityResultTest1",
312            abilityName: "com.example.test.MainAbility",
313            action: "action1",
314            entities: ["entity1"],
315            type: "MIMETYPE",
316            uri: "key={true,true,false}",
317            parameters:
318            {
319                mykey0: 2222,
320                mykey1: [1, 2, 3],
321                mykey2: "[1, 2, 3]",
322                mykey3: "ssssssssssssssssssssssssss",
323                mykey4: [false, true, false],
324                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
325                mykey6: true,
326            }
327        }
328    ],
329    operationType: OperationType.START_ABILITIES,
330    requestCode: 0,
331    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
332}
333
334WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
335
336// getUid callback
337function getUidCallback(err, data) {
338	console.info("==========================>getUidCallback=======================>");
339}
340WantAgent.getUid(wantAgent, getUidCallback)
341```
342
343
344
345## WantAgent.getUid
346
347getUid(agent: WantAgent): Promise\<number\>
348
349Obtains the user ID of a **WantAgent** object. This API uses a promise to return the result.
350
351**System capability**: SystemCapability.Ability.AbilityRuntime.Core
352
353**Parameters**
354
355| Name | Readable| Writable| Type     | Mandatory| Description         |
356| ----- | --- | ---- | --------- | ---- | ------------- |
357| agent | Yes  | No | WantAgent | Yes  | Target **WantAgent** object.|
358
359**Return value**
360
361| Type                                                       | Description                                                        |
362| ----------------------------------------------------------- | ------------------------------------------------------------ |
363| Promise\<number\> | Promise used to return the user ID.|
364
365**Example**
366
367```js
368import WantAgent from '@ohos.wantAgent';
369import { OperationType, WantAgentFlags } from '@ohos.wantagent';
370
371// WantAgent object
372var wantAgent;
373
374// WantAgentInfo object
375var wantAgentInfo = {
376    wants: [
377        {
378            deviceId: "deviceId",
379            bundleName: "com.neu.setResultOnAbilityResultTest1",
380            abilityName: "com.example.test.MainAbility",
381            action: "action1",
382            entities: ["entity1"],
383            type: "MIMETYPE",
384            uri: "key={true,true,false}",
385            parameters:
386            {
387                mykey0: 2222,
388                mykey1: [1, 2, 3],
389                mykey2: "[1, 2, 3]",
390                mykey3: "ssssssssssssssssssssssssss",
391                mykey4: [false, true, false],
392                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
393                mykey6: true,
394            }
395        }
396    ],
397    operationType: OperationType.START_ABILITIES,
398    requestCode: 0,
399    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
400}
401
402WantAgent.getWantAgent(wantAgentInfo).then((data) => {
403	console.info("==========================>getWantAgentCallback=======================>");
404    wantAgent = data;
405});
406
407WantAgent.getUid(wantAgent).then((data) => {
408	console.info("==========================>getUidCallback=======================>");
409});
410```
411
412
413
414## WantAgent.getWant
415
416getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void
417
418Obtains the want in a **WantAgent** object. This API uses an asynchronous callback to return the result.
419
420**System capability**: SystemCapability.Ability.AbilityRuntime.Core
421
422**Parameters**
423
424| Name    | Readable| Writable| Type                 | Mandatory| Description                           |
425| -------- | --- | ---- | --------------------- | ---- | ------------------------------- |
426| agent    | Yes  | No | WantAgent             | Yes  | Target **WantAgent** object.                  |
427| callback | Yes  | No | AsyncCallback\<Want\> | Yes  | Callback used to return the want.|
428
429**Example**
430
431```js
432import WantAgent from '@ohos.wantAgent';
433import { OperationType, WantAgentFlags } from '@ohos.wantagent';
434
435// WantAgent object
436var wantAgent;
437
438// getWantAgent callback
439function getWantAgentCallback(err, data) {
440	console.info("==========================>getWantAgentCallback=======================>");
441    if (err.code == 0) {
442    	wantAgent = data;
443    } else {
444        console.info('----getWantAgent failed!----');
445    }
446}
447// WantAgentInfo object
448var wantAgentInfo = {
449    wants: [
450        {
451            deviceId: "deviceId",
452            bundleName: "com.neu.setResultOnAbilityResultTest1",
453            abilityName: "com.example.test.MainAbility",
454            action: "action1",
455            entities: ["entity1"],
456            type: "MIMETYPE",
457            uri: "key={true,true,false}",
458            parameters:
459            {
460                mykey0: 2222,
461                mykey1: [1, 2, 3],
462                mykey2: "[1, 2, 3]",
463                mykey3: "ssssssssssssssssssssssssss",
464                mykey4: [false, true, false],
465                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
466                mykey6: true,
467            }
468        }
469    ],
470    operationType: OperationType.START_ABILITIES,
471    requestCode: 0,
472    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
473}
474
475WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
476
477// getWant callback
478function getWantCallback(err, data) {
479	console.info("==========================>getWantCallback=======================>");
480}
481WantAgent.getWant(wantAgent, getWantCallback)
482```
483
484
485
486## WantAgent.getWant
487
488getWant(agent: WantAgent): Promise\<Want\>
489
490Obtains the want in a **WantAgent** object. This API uses a promise to return the result.
491
492**System capability**: SystemCapability.Ability.AbilityRuntime.Core
493
494**Parameters**
495
496| Name | Readable| Writable| Type     | Mandatory| Description         |
497| ----- | --- | ---- | --------- | ---- | ------------- |
498| agent | Yes  | No | WantAgent | Yes  | Target **WantAgent** object.|
499
500**Return value**
501
502| Type                                                       | Description                                                        |
503| ----------------------------------------------------------- | ------------------------------------------------------------ |
504| Promise\<Want\> | Promise used to return the want.|
505
506**Example**
507
508```js
509import WantAgent from '@ohos.wantAgent';
510import { OperationType, WantAgentFlags } from '@ohos.wantagent';
511
512// WantAgent object
513var wantAgent;
514
515// WantAgentInfo object
516var wantAgentInfo = {
517    wants: [
518        {
519            deviceId: "deviceId",
520            bundleName: "com.neu.setResultOnAbilityResultTest1",
521            abilityName: "com.example.test.MainAbility",
522            action: "action1",
523            entities: ["entity1"],
524            type: "MIMETYPE",
525            uri: "key={true,true,false}",
526            parameters:
527            {
528                mykey0: 2222,
529                mykey1: [1, 2, 3],
530                mykey2: "[1, 2, 3]",
531                mykey3: "ssssssssssssssssssssssssss",
532                mykey4: [false, true, false],
533                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
534                mykey6: true,
535            }
536        }
537    ],
538    operationType: OperationType.START_ABILITIES,
539    requestCode: 0,
540    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
541}
542
543WantAgent.getWantAgent(wantAgentInfo).then((data) => {
544	console.info("==========================>getWantAgentCallback=======================>");
545    wantAgent = data;
546});
547
548WantAgent.getWant(wantAgent).then((data) => {
549	console.info("==========================>getWantCallback=======================>");
550});
551```
552
553
554
555## WantAgent.cancel
556
557cancel(agent: WantAgent, callback: AsyncCallback\<void\>): void
558
559Cancels a **WantAgent** object. This API uses an asynchronous callback to return the result.
560
561**System capability**: SystemCapability.Ability.AbilityRuntime.Core
562
563**Parameters**
564
565| Name    | Readable| Writable| Type                 | Mandatory| Description                       |
566| -------- | --- | ---- | --------------------- | ---- | --------------------------- |
567| agent    | Yes  | No | WantAgent             | Yes  | Target **WantAgent** object.              |
568| callback | Yes  | No | AsyncCallback\<void\> | Yes  | Callback used to return the result.|
569
570**Example**
571
572```js
573import WantAgent from '@ohos.wantAgent';
574import { OperationType, WantAgentFlags } from '@ohos.wantagent';
575
576// WantAgent object
577var wantAgent;
578
579// getWantAgent callback
580function getWantAgentCallback(err, data) {
581	console.info("==========================>getWantAgentCallback=======================>");
582    if (err.code == 0) {
583    	wantAgent = data;
584    } else {
585        console.info('----getWantAgent failed!----');
586    }
587}
588// WantAgentInfo object
589var wantAgentInfo = {
590    wants: [
591        {
592            deviceId: "deviceId",
593            bundleName: "com.neu.setResultOnAbilityResultTest1",
594            abilityName: "com.example.test.MainAbility",
595            action: "action1",
596            entities: ["entity1"],
597            type: "MIMETYPE",
598            uri: "key={true,true,false}",
599            parameters:
600            {
601                mykey0: 2222,
602                mykey1: [1, 2, 3],
603                mykey2: "[1, 2, 3]",
604                mykey3: "ssssssssssssssssssssssssss",
605                mykey4: [false, true, false],
606                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
607                mykey6: true,
608            }
609        }
610    ],
611    operationType: OperationType.START_ABILITIES,
612    requestCode: 0,
613    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
614}
615
616WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
617
618// cancel callback
619function cancelCallback(err, data) {
620	console.info("==========================>cancelCallback=======================>");
621}
622WantAgent.cancel(wantAgent, cancelCallback)
623```
624
625
626
627## WantAgent.cancel
628
629cancel(agent: WantAgent): Promise\<void\>
630
631Cancels a **WantAgent** object. This API uses a promise to return the result.
632
633**System capability**: SystemCapability.Ability.AbilityRuntime.Core
634
635**Parameters**
636
637| Name | Readable| Writable| Type     | Mandatory| Description         |
638| ----- | --- | ---- | --------- | ---- | ------------- |
639| agent | Yes  | No | WantAgent | Yes  | Target **WantAgent** object.|
640
641**Return value**
642
643| Type           | Description                           |
644| --------------- | ------------------------------- |
645| Promise\<void\> | Promise used to return the result.|
646
647**Example**
648
649```js
650import WantAgent from '@ohos.wantAgent';
651import { OperationType, WantAgentFlags } from '@ohos.wantagent';
652
653// WantAgent object
654var wantAgent;
655
656// WantAgentInfo object
657var wantAgentInfo = {
658    wants: [
659        {
660            deviceId: "deviceId",
661            bundleName: "com.neu.setResultOnAbilityResultTest1",
662            abilityName: "com.example.test.MainAbility",
663            action: "action1",
664            entities: ["entity1"],
665            type: "MIMETYPE",
666            uri: "key={true,true,false}",
667            parameters:
668            {
669                mykey0: 2222,
670                mykey1: [1, 2, 3],
671                mykey2: "[1, 2, 3]",
672                mykey3: "ssssssssssssssssssssssssss",
673                mykey4: [false, true, false],
674                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
675                mykey6: true,
676            }
677        }
678    ],
679    operationType: OperationType.START_ABILITIES,
680    requestCode: 0,
681    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
682}
683
684WantAgent.getWantAgent(wantAgentInfo).then((data) => {
685	console.info("==========================>getWantAgentCallback=======================>");
686    wantAgent = data;
687});
688
689WantAgent.cancel(wantAgent).then((data) => {
690	console.info("==========================>cancelCallback=======================>");
691});
692```
693
694
695
696## WantAgent.trigger
697
698trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback\<CompleteData\>): void
699
700Triggers a **WantAgent** object. This API uses an asynchronous callback to return the result.
701
702**System capability**: SystemCapability.Ability.AbilityRuntime.Core
703
704**Parameters**
705
706| Name       | Readable| Writable| Type                         | Mandatory| Description                           |
707| ----------- | --- | ---- | ----------------------------- | ---- | ------------------------------- |
708| agent       | Yes  | No | WantAgent                     | Yes  | **WantAgent** object to trigger.                  |
709| triggerInfo | Yes  | No | TriggerInfo                   | Yes  | **TriggerInfo** object.                |
710| callback    | Yes  | No | AsyncCallback\<CompleteData\> | Yes  | Callback used to return the result.|
711
712**Example**
713
714```js
715import WantAgent from '@ohos.wantAgent';
716import { OperationType, WantAgentFlags } from '@ohos.wantagent';
717
718// WantAgent object
719var wantAgent;
720
721// getWantAgent callback
722function getWantAgentCallback(err, data) {
723	console.info("==========================>getWantAgentCallback=======================>");
724    if (err.code == 0) {
725    	wantAgent = data;
726    } else {
727        console.info('----getWantAgent failed!----');
728    }
729}
730// WantAgentInfo object
731var wantAgentInfo = {
732    wants: [
733        {
734            deviceId: "deviceId",
735            bundleName: "com.neu.setResultOnAbilityResultTest1",
736            abilityName: "com.example.test.MainAbility",
737            action: "action1",
738            entities: ["entity1"],
739            type: "MIMETYPE",
740            uri: "key={true,true,false}",
741            parameters:
742            {
743                mykey0: 2222,
744                mykey1: [1, 2, 3],
745                mykey2: "[1, 2, 3]",
746                mykey3: "ssssssssssssssssssssssssss",
747                mykey4: [false, true, false],
748                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
749                mykey6: true,
750            }
751        }
752    ],
753    operationType: OperationType.START_ABILITIES,
754    requestCode: 0,
755    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
756}
757
758WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
759
760// trigger callback
761function triggerCallback(err, data) {
762	console.info("==========================>triggerCallback=======================>");
763}
764
765var triggerInfo = {
766    code:0
767}
768WantAgent.trigger(wantAgent, triggerInfo, triggerCallback)
769```
770
771
772
773## WantAgent.equal
774
775equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback\<boolean\>): void
776
777Checks whether two **WantAgent** objects are equal. This API uses an asynchronous callback to return the result.
778
779**System capability**: SystemCapability.Ability.AbilityRuntime.Core
780
781**Parameters**
782
783| Name      | Readable| Writable| Type                    | Mandatory| Description                                   |
784| ---------- | --- | ---- | ------------------------ | ---- | --------------------------------------- |
785| agent      | Yes  | No | WantAgent                | Yes  | The first **WantAgent** object.                          |
786| otherAgent | Yes  | No | WantAgent                | Yes  | The second **WantAgent** object.                 |
787| callback   | Yes  | No | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.|
788
789**Example**
790
791```js
792import WantAgent from '@ohos.wantAgent';
793import { OperationType, WantAgentFlags } from '@ohos.wantagent';
794
795// WantAgent object
796var wantAgent1;
797var wantAgent2;
798
799// getWantAgent callback
800function getWantAgentCallback(err, data) {
801	console.info("==========================>getWantAgentCallback=======================>");
802    if (err.code == 0) {
803    	wantAgent1 = data;
804        wantAgent2 = data;
805    } else {
806        console.info('----getWantAgent failed!----');
807    }
808}
809// WantAgentInfo object
810var wantAgentInfo = {
811    wants: [
812        {
813            deviceId: "deviceId",
814            bundleName: "com.neu.setResultOnAbilityResultTest1",
815            abilityName: "com.example.test.MainAbility",
816            action: "action1",
817            entities: ["entity1"],
818            type: "MIMETYPE",
819            uri: "key={true,true,false}",
820            parameters:
821            {
822                mykey0: 2222,
823                mykey1: [1, 2, 3],
824                mykey2: "[1, 2, 3]",
825                mykey3: "ssssssssssssssssssssssssss",
826                mykey4: [false, true, false],
827                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
828                mykey6: true,
829            }
830        }
831    ],
832    operationType: OperationType.START_ABILITIES,
833    requestCode: 0,
834    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
835}
836
837WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
838
839// equal callback
840function equalCallback(err, data) {
841	console.info("==========================>equalCallback=======================>");
842}
843WantAgent.equal(wantAgent1, wantAgent2, equalCallback)
844```
845
846
847
848## WantAgent.equal
849
850equal(agent: WantAgent, otherAgent: WantAgent): Promise\<boolean\>
851
852Checks whether two **WantAgent** objects are equal. This API uses a promise to return the result.
853
854**System capability**: SystemCapability.Ability.AbilityRuntime.Core
855
856**Parameters**
857
858| Name      | Readable| Writable| Type     | Mandatory| Description         |
859| ---------- | --- | ---- | --------- | ---- | ------------- |
860| agent      | Yes  | No | WantAgent | Yes  | The first **WantAgent** object.|
861| otherAgent | Yes  | No | WantAgent | Yes  | The second **WantAgent** object. |
862
863**Return value**
864
865| Type                                                       | Description                                                        |
866| ----------------------------------------------------------- | ------------------------------------------------------------ |
867| Promise\<boolean\> | Promise used to return the result.|
868
869**Example**
870
871```js
872import WantAgent from '@ohos.wantAgent';
873import { OperationType, WantAgentFlags } from '@ohos.wantagent';
874
875// WantAgent object
876var wantAgent1;
877var wantAgent2;
878
879// WantAgentInfo object
880var wantAgentInfo = {
881    wants: [
882        {
883            deviceId: "deviceId",
884            bundleName: "com.neu.setResultOnAbilityResultTest1",
885            abilityName: "com.example.test.MainAbility",
886            action: "action1",
887            entities: ["entity1"],
888            type: "MIMETYPE",
889            uri: "key={true,true,false}",
890            parameters:
891            {
892                mykey0: 2222,
893                mykey1: [1, 2, 3],
894                mykey2: "[1, 2, 3]",
895                mykey3: "ssssssssssssssssssssssssss",
896                mykey4: [false, true, false],
897                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
898                mykey6: true,
899            }
900        }
901    ],
902    operationType: OperationType.START_ABILITIES,
903    requestCode: 0,
904    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
905}
906
907WantAgent.getWantAgent(wantAgentInfo).then((data) => {
908	console.info("==========================>getWantAgentCallback=======================>");
909    wantAgent1 = data;
910    wantAgent2 = data;
911});
912
913WantAgent.equal(wantAgent1, wantAgent2).then((data) => {
914	console.info("==========================>equalCallback=======================>");
915});
916```
917
918
919## WantAgent.getOperationType<sup>9+</sup>
920
921getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void
922
923Obtains the operation type of a **WantAgent** object. This API uses an asynchronous callback to return the result.
924
925**System capability**: SystemCapability.Ability.AbilityRuntime.Core
926
927**Parameters**
928
929| Name     | Readable | Writable | Type                   | Mandatory | Description                                 |
930| ---------- | --- | ---- | --------- | ---- | ------------- |
931| agent      | Yes | No  | WantAgent | Yes | Target **WantAgent** object. |
932| callback   | Yes | No | AsyncCallback\<number> | Yes | Callback used to return the operation type. |
933
934**Example**
935
936```js
937import WantAgent from '@ohos.wantAgent';
938
939// wantAgent object
940var wantAgent;
941
942// WantAgentInfo object
943var wantAgentInfo = {
944    wants: [
945        {
946            deviceId: "deviceId",
947            bundleName: "com.neu.setResultOnAbilityResultTest1",
948            abilityName: "com.example.test.MainAbility",
949            action: "action1",
950            entities: ["entity1"],
951            type: "MIMETYPE",
952            uri: "key={true,true,false}",
953            parameters:
954            {
955                mykey0: 2222,
956                mykey1: [1, 2, 3],
957                mykey2: "[1, 2, 3]",
958                mykey3: "ssssssssssssssssssssssssss",
959                mykey4: [false, true, false],
960                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
961                mykey6: true,
962            }
963        }
964    ],
965    requestCode: 0,
966    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
967}
968
969WantAgent.getWantAgent(wantAgentInfo).then((data) => {
970	console.info("==========================>getWantAgentCallback=======================>");
971    wantAgent = data;
972});
973
974WantAgent.getOperationType(wantAgent, (OperationType) => {
975    console.log('----------- getOperationType ----------, OperationType: ' + OperationType);
976})
977```
978
979
980## WantAgent.getOperationType<sup>9+</sup>
981
982getOperationType(agent: WantAgent): Promise\<number>
983
984Obtains the operation type of a **WantAgent** object. This API uses a promise to return the result.
985
986**System capability**: SystemCapability.Ability.AbilityRuntime.Core
987
988**Parameters**
989
990| Name  | Readable | Writable | Type      | Mandatory | Description   |
991| ---------- | --- | ---- | --------- | ---- | ------------- |
992| agent      | Yes | No | WantAgent | Yes | Target **WantAgent** object. |
993
994**Return value**
995
996| Type              | Description                                |
997| ----------------- | ------------------------------------------ |
998| Promise\<number> | Promise used to return the operation type. |
999
1000
1001**Example**
1002
1003```js
1004import WantAgent from '@ohos.wantAgent';
1005
1006// wantAgent object
1007var wantAgent;
1008
1009// WantAgentInfo object
1010var wantAgentInfo = {
1011    wants: [
1012        {
1013            deviceId: "deviceId",
1014            bundleName: "com.neu.setResultOnAbilityResultTest1",
1015            abilityName: "com.example.test.MainAbility",
1016            action: "action1",
1017            entities: ["entity1"],
1018            type: "MIMETYPE",
1019            uri: "key={true,true,false}",
1020            parameters:
1021            {
1022                mykey0: 2222,
1023                mykey1: [1, 2, 3],
1024                mykey2: "[1, 2, 3]",
1025                mykey3: "ssssssssssssssssssssssssss",
1026                mykey4: [false, true, false],
1027                mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
1028                mykey6: true,
1029            }
1030        }
1031    ],
1032    requestCode: 0,
1033    wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
1034}
1035
1036WantAgent.getWantAgent(wantAgentInfo).then((data) => {
1037	console.info("==========================>getWantAgentCallback=======================>");
1038    wantAgent = data;
1039});
1040
1041WantAgent.getOperationType(wantAgent).then((OperationType) => {
1042    console.log('getOperationType success, OperationType: ' + OperationType);
1043}).catch((err) => {
1044    console.log('getOperationType fail, err: ' + err);
1045})
1046```
1047
1048
1049## WantAgentInfo
1050
1051**System capability**: SystemCapability.Ability.AbilityRuntime.Core
1052
1053| Name          | Readable| Writable| Type                           | Mandatory| Description                  |
1054| -------------- | --- | ---- | ------------------------------- | ---- | ---------------------- |
1055| wants          | Yes | Yes | Array\<Want\>                   | Yes  | Array of all **Want** objects.    |
1056| operationType  | Yes | Yes | wantAgent.OperationType         | Yes  | Action type.              |
1057| requestCode    | Yes | Yes | number                          | Yes  | Request code defined by the user.|
1058| wantAgentFlags | Yes | Yes | Array<wantAgent.WantAgentFlags> | No  | Array of flags for using the **WantAgent** object.          |
1059| extraInfo      | Yes | Yes | {[key: string]: any}            | No  | Extra information.              |
1060
1061
1062
1063## WantAgentFlags
1064
1065**System capability**: SystemCapability.Ability.AbilityRuntime.Core
1066
1067| Name               | Value            | Description                                                        |
1068| ------------------- | -------------- | ------------------------------------------------------------ |
1069| ONE_TIME_FLAG       | WantAgentFlags | The **WantAgent** object can be used only once.                                     |
1070| NO_BUILD_FLAG       | WantAgentFlags | The **WantAgent** object does not exist and hence it is not created. In this case, **null** is returned.     |
1071| CANCEL_PRESENT_FLAG | WantAgentFlags | The existing **WantAgent** object should be canceled before a new object is generated.|
1072| UPDATE_PRESENT_FLAG | WantAgentFlags | Extra information of the existing **WantAgent** object is replaced with that of the new object.|
1073| CONSTANT_FLAG       | WantAgentFlags | The **WantAgent** object is immutable.                                       |
1074| REPLACE_ELEMENT     | WantAgentFlags | The **element** attribute of the current **Want** can be replaced by the **element** attribute of the **Want** in **WantAgent.trigger()**.|
1075| REPLACE_ACTION      | WantAgentFlags | The **action** attribute of the current **Want** can be replaced by the **action** attribute of the **Want** in **WantAgent.trigger()**.|
1076| REPLACE_URI         | WantAgentFlags | The **uri** attribute of the current **Want** can be replaced by the **uri** attribute of the **Want** in **WantAgent.trigger()**.|
1077| REPLACE_ENTITIES    | WantAgentFlags | The **entities** attribute of the current **Want** can be replaced by the **entities** attribute of the **Want** in **WantAgent.trigger()**.|
1078| REPLACE_BUNDLE      | WantAgentFlags | The **bundleName** attribute of the current **Want** can be replaced by the **bundleName** attribute of **Want** in **WantAgent.trigger()**.|
1079
1080
1081
1082## OperationType
1083
1084**System capability**: SystemCapability.Ability.AbilityRuntime.Core
1085
1086| Name             | Value           | Description                     |
1087| ----------------- | ------------- | ------------------------- |
1088| UNKNOWN_TYPE      | OperationType | Unknown operation type.           |
1089| START_ABILITY     | OperationType | Starts an ability with a UI.|
1090| START_ABILITIES   | OperationType | Starts multiple abilities with a UI.|
1091| START_SERVICE     | OperationType | Starts an ability without a UI.|
1092| SEND_COMMON_EVENT | OperationType | Sends a common event.       |
1093
1094
1095
1096## CompleteData
1097
1098**System capability**: SystemCapability.Ability.AbilityRuntime.Core
1099
1100| Name          | Readable| Writable| Type                          | Mandatory| Description                   |
1101| -------------- | --- | ---- | ------------------------------ | ---- | ---------------------- |
1102| info           | Yes | Yes | WantAgent                       | Yes  | A triggered **WantAgent** object.      |
1103| want           | Yes | Yes | Want                            | Yes  | An existing triggered **want**.    |
1104| finalCode      | Yes | Yes | number                          | Yes  | Request code that triggers the **WantAgent** object.|
1105| finalData      | Yes | Yes | string                          | No  | Final data collected by the common event. |
1106| extraInfo      | Yes | Yes | {[key: string]: any}            | No  | Extra information.              |
1107
1108
1109
1110## TriggerInfo
1111
1112**System capability**: SystemCapability.Ability.AbilityRuntime.Core
1113
1114| Name      | Readable| Writable| Type                | Mandatory| Description       |
1115| ---------- | --- | ---- | -------------------- | ---- | ----------- |
1116| code       | Yes | Yes | number               | Yes  | Result code.|
1117| want       | Yes | Yes | Want                 | No  | Want.       |
1118| permission | Yes | Yes | string               | No  | Permission.   |
1119| extraInfo  | Yes | Yes | {[key: string]: any} | No  | Extra information.   |
1120