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