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