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