• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.app.ability.insightIntentDriver (Intent Call Execution) (System API)
2
3<!--Kit: Ability Kit-->
4<!--Subsystem: Ability-->
5<!--Owner: @linjunjie6-->
6<!--Designer: @li-weifeng2-->
7<!--Tester: @lixueqing513-->
8<!--Adviser: @huipeizi-->
9
10The module provides APIs for executing intent calls. The system executes intent calls based on user interaction and more.
11
12> **NOTE**
13>
14> The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
15>
16> The APIs of this module can be used only in the stage model.
17>
18> The APIs provided by this module are system APIs.
19>
20> Starting from API version 20, this module supports application navigation using intents defined by the [@InsightIntentLink](js-apis-app-ability-InsightIntentDecorator.md#insightintentlink) decorator.
21
22## Modules to Import
23
24```ts
25import { insightIntentDriver } from '@kit.AbilityKit';
26```
27
28## ExecuteParam
29
30Defines the parameter used to execute an intent call.
31
32**Model restriction**: This API can be used only in the stage model.
33
34**System API**: This is a system API.
35
36**System capability**: SystemCapability.Ability.AbilityRuntime.Core
37
38| Name| Type| Read-Only| Optional| Description|
39| -------- | -------- | --- |----- | -------- |
40| bundleName | string | No| No| Name of the bundle to which the ability to be called belongs.|
41| moduleName | string | No| No| Name of the module to which the ability belongs.|
42| abilityName | string | No| No| Name of the ability to be called. If an intent defined by the [@InsightIntentLink](js-apis-app-ability-InsightIntentDecorator.md#insightintentlink) decorator is used to implement application redirection, this parameter can be left empty.|
43| insightIntentName | string | No| No| Intent name.|
44| insightIntentParam | Record\<string, Object> | No| No| Intent call parameter.|
45| executeMode | [insightIntent.ExecuteMode](js-apis-app-ability-insightIntent.md#executemode) | No| No| Intent call execution mode. If an intent defined by the [@InsightIntentLink](js-apis-app-ability-InsightIntentDecorator.md#insightintentlink) decorator is used to implement application redirection, this parameter must be filled (with any value that conforms to the definition), although it will not actually take effect.|
46| displayId<sup>12+</sup> | number | No| Yes| Physical screen ID specified during intent call. The value must be an integer. This parameter is valid only when **executeMode** is set to **UI_ABILITY_FOREGROUND**.|
47| uris<sup>18+</sup> | Array&lt;string&gt; | No| Yes| List of URIs authorized by the intent caller to the intent executor during the call. If an intent defined by the [@InsightIntentLink](js-apis-app-ability-InsightIntentDecorator.md#insightintentlink) decorator is used to implement application redirection, this field is mandatory. Only the first element in the array is read as the URI of [openLink](js-apis-inner-application-uiAbilityContext.md#openlink12).|
48| flags<sup>18+</sup> | number | No| Yes| [Flags](js-apis-app-ability-wantConstant.md#flags) of the URIs authorized by the intent caller to the intent executor during the call.<br>**NOTE**<br>This parameter supports only **FLAG_AUTH_READ_URI_PERMISSION**, **FLAG_AUTH_WRITE_URI_PERMISSION**, and FLAG_AUTH_READ_URI_PERMISSION\||FLAG_AUTH_WRITE_URI_PERMISSION.|
49
50## InsightIntentType<sup>20+<sup>
51
52Enumerates the intent types defined by the intent decorator. You can obtain the intent type from [LinkIntentInfo](#linkintentinfo20) returned by calling APIs such as [getAllInsightIntentInfo](#insightintentdrivergetallinsightintentinfo20).
53
54**System capability**: SystemCapability.Ability.AbilityRuntime.Core
55
56| Name| Value| Description|
57| -------- | -------- | -------- |
58| LINK | @InsightIntentLink | A decorator of the [@InsightIntentLink](./js-apis-app-ability-InsightIntentDecorator.md#insightintentlink) type.|
59| PAGE | @InsightIntentPage | A decorator of the [@InsightIntentPage](./js-apis-app-ability-InsightIntentDecorator.md#insightintentpage) type.|
60| ENTRY | @InsightIntentEntry | A decorator of the [@InsightIntentEntry](./js-apis-app-ability-InsightIntentDecorator.md#insightintententry) type.|
61| FUNCTION | @InsightIntentFunctionMethod | A decorator of the [@InsightIntentFunctionMethod](./js-apis-app-ability-InsightIntentDecorator.md#insightintentfunctionmethod) type.|
62| FORM | @InsightIntentForm | A decorator of the [@InsightIntentForm](./js-apis-app-ability-InsightIntentDecorator.md#insightintentform) type.|
63
64## LinkIntentInfo<sup>20+<sup>
65
66LinkIntentInfo inherits from [IntentDecoratorInfo](./js-apis-app-ability-InsightIntentDecorator.md#intentdecoratorinfo). It is used to describe parameters supported by the [@InsightIntentLink](./js-apis-app-ability-InsightIntentDecorator.md#insightintentlink) decorator, such as the URI required for application redirection.
67
68**Model restriction**: This API can be used only in the stage model.
69
70**System API**: This is a system API.
71
72**System capability**: SystemCapability.Ability.AbilityRuntime.Core
73
74| Name| Type| Read-Only| Optional| Description|
75| -------- | -------- | -------- | -------- |-------- |
76| uri | string | Yes| No| URI of an intent.|
77
78## PageIntentInfo<sup>20+<sup>
79
80PageIntentInfo inherits from [IntentDecoratorInfo](./js-apis-app-ability-InsightIntentDecorator.md#intentdecoratorinfo). It is used to describe parameters supported by the [@InsightIntentPage](./js-apis-app-ability-InsightIntentDecorator.md#insightintentpage) decorator, such as the name of [NavDestination](../apis-arkui/arkui-ts/ts-basic-components-navigation.md#navdestination10) of the target page.
81
82**Model restriction**: This API can be used only in the stage model.
83
84**System API**: This is a system API.
85
86**System capability**: SystemCapability.Ability.AbilityRuntime.Core
87
88| Name| Type| Read-Only| Optional| Description|
89| -------- | -------- | -------- | -------- |-------- |
90| uiAbility | string | Yes| No| Ability name.|
91| pageRouterName | string | Yes| No| Page name.|
92| navigationId | string | Yes| No|  ID of the [Navigation](../apis-arkui/arkui-ts/ts-basic-components-navigation.md) component bound to the intent.|
93| navDestination | string | Yes| No| Name of the [NavDestination](../apis-arkui/arkui-ts/ts-basic-components-navigation.md#navdestination10) component bound to the intent.|
94
95## FunctionIntentInfo<sup>20+<sup>
96
97Defines the parameter type of the [@InsightIntentFunctionMethod](./js-apis-app-ability-InsightIntentDecorator.md#insightintentfunctionmethod) decorator. All parameters inherit from [IntentDecoratorInfo](./js-apis-app-ability-InsightIntentDecorator.md#intentdecoratorinfo).
98
99**Model restriction**: This API can be used only in the stage model.
100
101**System API**: This is a system API.
102
103**System capability**: SystemCapability.Ability.AbilityRuntime.Core
104
105## EntityInfo<sup>20+<sup>
106
107EntityInfo inherits from [IntentEntityDecoratorInfo](./js-apis-app-ability-InsightIntentDecorator.md#intententitydecoratorinfo) and is used to describe the information about the intent entity defined by the [@InsightIntentEntity](./js-apis-app-ability-InsightIntentDecorator.md#insightintententity) decorator.
108
109**Model restriction**: This API can be used only in the stage model.
110
111**System API**: This is a system API.
112
113**System capability**: SystemCapability.Ability.AbilityRuntime.Core
114
115| Name| Type| Read-Only| Optional| Description|
116| -------- | -------- | -------- | -------- |-------- |
117| className | string | Yes| No| Class name decorated by [@InsightIntentEntity](./js-apis-app-ability-InsightIntentDecorator.md#insightintententity).|
118| entityId | string | Yes| No| ID of the intent entity.|
119| entityCategory | string | Yes| No| Category of the intent entity.|
120| parameters | string | Yes| No| Data format of intent entity parameters.|
121| parentClassName | string | Yes| No| Parent class name decorated by [@InsightIntentEntity](./js-apis-app-ability-InsightIntentDecorator.md#insightintententity).|
122
123## InsightIntentInfo<sup>20+<sup>
124
125Defines the intent information, which is the specific parameter configuration of the intent in the device.
126
127**Model restriction**: This API can be used only in the stage model.
128
129**System API**: This is a system API.
130
131**System capability**: SystemCapability.Ability.AbilityRuntime.Core
132
133| Name| Type| Read-Only| Optional| Description|
134| -------- | -------- | -------- | -------- |-------- |
135| bundleName | string | Yes| No| Bundle name of the application.|
136| moduleName | string | Yes| No| Module name.|
137| intentName | string | Yes| No| Intent name.|
138| domain | string | Yes| No| Vertical domain of the intent. It is used to categorize intents by vertical fields (for example, video, music, and games). For details about the value range, see the vertical domain fields in [smart distribution features in different vertical domains](https://developer.huawei.com/consumer/en/doc/service/intents-ai-distribution-characteristic-0000001901922213#section2656133582215).|
139| intentVersion | string | Yes| No| Version number of the intent. It is used to distinguish and manage intents when their capabilities evolve.|
140| displayName | string | Yes| No| Name of the intent displayed in the InsightIntent framework.|
141| displayDescription | string | Yes| No| Description of the intent displayed in the InsightIntent framework.|
142| schema | string | Yes| No| Standard intent name. If an intent in the standard intent list matches both the **schema** and **intentVersion** fields, it is processed as a standard intent.|
143| icon | string | Yes| No| Icon of the intent.|
144| llmDescription | string | Yes| No| Function of an intent, which helps large language models understand the intent.|
145| keywords | Array&lt;string&gt; | Yes| No| Search keywords for the intent.|
146| intentType | [InsightIntentType](#insightintenttype20) | Yes| No| Type of intent defined by the intent decorator.|
147| subIntentInfo | [LinkIntentInfo](#linkintentinfo20) \| [PageIntentInfo](#pageintentinfo20) \| [FunctionIntentInfo](#functionintentinfo20) | Yes| No| Intent information for specific intent decorators.|
148| parameters | Record<string, Object> | Yes| No| Data format of intent parameters, which is used to define the input data format during intent calls.|
149| entities | Array&lt;[EntityInfo](#entityinfo20)&gt; | Yes| No| Entity information contained in the intent.|
150
151## GetInsightIntentFlag<sup>20+<sup>
152
153Enumerates the flags of intent information ([InsightIntentInfo](#insightintentinfo20)). It is used in [getAllInsightIntentInfo](#insightintentdrivergetinsightintentinfobybundlename20), [getInsightIntentInfoByBundleName](#insightintentdrivergetinsightintentinfobybundlename20), and [getInsightIntentInfoByIntentName](#insightintentdrivergetinsightintentinfobyintentname20).
154
155**System capability**: SystemCapability.Ability.AbilityRuntime.Core
156
157| Name| Value| Description|
158| -------- | -------- | -------- |
159| GET_FULL_INSIGHT_INTENT | 0x00000001 | Used to query all intent information (except entities) in [InsightIntentInfo](#insightintentinfo20). To query entities information, use **GET_ENTITY_INFO**.|
160| GET_SUMMARY_INSIGHT_INTENT | 0x00000002 | Used to query brief intent information in [InsightIntentInfo](#insightintentinfo20).|
161| GET_ENTITY_INFO | 0x00000004 | Used to query [EntityInfo](#entityinfo20). It must be used together with **GET_FULL_INSIGHT_INTENT** or **GET_SUMMARY_INSIGHT_INTENT**. Example usage: `GET_FULL_INSIGHT_INTENT \| GET_ENTITY_INFO`.|
162
163Table 1 Differences between full intent information and brief intent information
164
165| Name| Included in Full Intent Information| Included in Brief Intent Information|
166| -------- | -------- | -------- |
167| bundleName | Yes| Yes|
168| moduleName | Yes| Yes|
169| intentName | Yes| Yes|
170| domain | Yes| No|
171| intentVersion | Yes| No|
172| displayName | Yes| Yes|
173| displayDescription | Yes| No|
174| schema | Yes| No|
175| icon | Yes| No|
176| llmDescription | Yes| No|
177| keywords | Yes| No|
178| intentType | Yes| Yes|
179| subIntentInfo | Yes| Yes|
180| parameters | Yes| Yes|
181| entities | No| No|
182
183## insightIntentDriver.execute
184
185execute(param: ExecuteParam, callback: AsyncCallback<insightIntent.ExecuteResult>): void
186
187Executes a call to an intent. This API uses an asynchronous callback to return the result.
188
189When the caller is in the background, the ohos.permission.START_ABILITIES_FROM_BACKGROUND permission is required.
190
191When [ExecuteMode](js-apis-app-ability-insightIntent.md#executemode) of the intent call is set to **UI_ABILITY_BACKGROUND**, the ohos.permission.ABILITY_BACKGROUND_COMMUNICATION permission is required.
192
193**Model restriction**: This API can be used only in the stage model.
194
195**System API**: This is a system API.
196
197**Required permissions**: ohos.permission.EXECUTE_INSIGHT_INTENT
198
199**System capability**: SystemCapability.Ability.AbilityRuntime.Core
200
201**Parameters**
202
203  | Name| Type| Mandatory| Description|
204  | -------- | -------- | -------- | -------- |
205  | param | [ExecuteParam](#executeparam) | Yes| Parameter used to execute the intent call.|
206  | callback | AsyncCallback<[insightIntent.ExecuteResult](js-apis-app-ability-insightIntent.md#executeresult)> | Yes| Callback used to return the intent call execution result.|
207
208**Error codes**
209
210For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
211
212| ID| Error Message|
213| -------- | -------- |
214| 201      | Permission denied. |
215| 202      | Not system application. |
216| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
217| 16000001 | The specified ability does not exist. |
218| 16000002 | Incorrect ability type. |
219| 16000004 | Cannot start an invisible component. |
220| 16000005 | The specified process does not have the permission. |
221| 16000006 | Cross-user operations are not allowed. |
222| 16000008 | The crowdtesting application expires. |
223| 16000009 | An ability cannot be started or stopped in Wukong mode. |
224| 16000010 | The call with the continuation and prepare continuation flag is forbidden. |
225| 16000011 | The context does not exist.        |
226| 16000012 | The application is controlled.        |
227| 16000013 | The application is controlled by EDM.       |
228| 16000050 | Internal error. |
229| 16000053 | The ability is not on the top of the UI. |
230| 16000055 | Installation-free timed out. |
231
232**Example**
233
234```ts
235  import { insightIntentDriver, insightIntent } from '@kit.AbilityKit';
236  import { hilog } from '@kit.PerformanceAnalysisKit';
237
238  function executeInsightIntentAsync() {
239    let param: insightIntentDriver.ExecuteParam = {
240      bundleName: 'com.ohos.intentexecutedemo',
241      moduleName: 'entry',
242      abilityName: 'EntryAbility',
243      insightIntentName: 'PlayMusic',
244      insightIntentParam: {
245        songName: 'City Of Stars',
246      },
247      executeMode: insightIntent.ExecuteMode.UI_ABILITY_FOREGROUND,
248    };
249
250    try {
251      insightIntentDriver.execute(param, (error, data: insightIntent.ExecuteResult) => {
252        if (error) {
253          hilog.error(0x0000, 'testTag', 'execute insight intent failed with %{public}s', JSON.stringify(error));
254        } else {
255          hilog.info(0x0000, 'testTag', '%{public}s', 'execute insight intent succeed');
256        }
257        hilog.info(0x0000, 'testTag', 'execute insight intent return %{public}d', data.code);
258        hilog.info(0x0000, 'testTag', 'execute insight intent result %{public}s', JSON.stringify(data.result));
259      })
260    } catch (error) {
261      hilog.error(0x0000, 'testTag', 'execute insight intent error caught %{public}s', JSON.stringify(error));
262    }
263  }
264```
265
266## insightIntentDriver.execute
267
268execute(param: ExecuteParam): Promise<insightIntent.ExecuteResult>
269
270Executes a call to an intent. This API uses a promise to return the result.
271
272When the caller is in the background, the ohos.permission.START_ABILITIES_FROM_BACKGROUND permission is required.
273
274When [ExecuteMode](js-apis-app-ability-insightIntent.md#executemode) of the intent call is set to **UI_ABILITY_BACKGROUND**, the ohos.permission.ABILITY_BACKGROUND_COMMUNICATION permission is required.
275
276**Model restriction**: This API can be used only in the stage model.
277
278**System API**: This is a system API.
279
280**Required permissions**: ohos.permission.EXECUTE_INSIGHT_INTENT
281
282**System capability**: SystemCapability.Ability.AbilityRuntime.Core
283
284**Parameters**
285
286  | Name| Type| Mandatory| Description|
287  | -------- | -------- | -------- | -------- |
288  | param | [ExecuteParam](#executeparam) | Yes| Parameter used to execute the intent call.|
289
290**Return value**
291
292| Type| Description|
293| -------- | -------- |
294| Promise<[insightIntent.ExecuteResult](js-apis-app-ability-insightIntent.md#executeresult)> | Promise used to return the intent call execution result.|
295
296**Error codes**
297
298For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
299
300| ID| Error Message|
301| -------- | -------- |
302| 201      | Permission denied. |
303| 202      | Not system application. |
304| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
305| 16000001 | The specified ability does not exist. |
306| 16000002 | Incorrect ability type. |
307| 16000004 | Cannot start an invisible component. |
308| 16000005 | The specified process does not have the permission. |
309| 16000006 | Cross-user operations are not allowed. |
310| 16000008 | The crowdtesting application expires. |
311| 16000009 | An ability cannot be started or stopped in Wukong mode. |
312| 16000010 | The call with the continuation and prepare continuation flag is forbidden. |
313| 16000011 | The context does not exist.        |
314| 16000012 | The application is controlled.        |
315| 16000013 | The application is controlled by EDM.       |
316| 16000050 | Internal error. |
317| 16000053 | The ability is not on the top of the UI. |
318| 16000055 | Installation-free timed out. |
319
320**Example**
321
322```ts
323  import { insightIntentDriver, insightIntent } from '@kit.AbilityKit';
324  import { hilog } from '@kit.PerformanceAnalysisKit';
325
326  async function executeSearchMusicIntentPromise() {
327    let param: insightIntentDriver.ExecuteParam = {
328      bundleName: 'com.ohos.intentexecutedemo',
329      moduleName: 'entry',
330      abilityName: 'EntryAbility',
331      insightIntentName: 'PlayMusic',
332      insightIntentParam: {
333        songName: 'City Of Stars',
334      },
335      executeMode: insightIntent.ExecuteMode.UI_ABILITY_FOREGROUND,
336    };
337
338    try {
339      let resultData: insightIntent.ExecuteResult = await insightIntentDriver.execute(param);
340      hilog.info(0x0000, 'testTag', 'execute insight intent return %{public}d', resultData.code);
341      hilog.info(0x0000, 'testTag', 'execute insight intent result %{public}s', JSON.stringify(resultData.result));
342    } catch (error) {
343      hilog.error(0x0000, 'testTag', 'execute insight intent error caught %{public}s', JSON.stringify(error));
344    }
345  }
346```
347
348## insightIntentDriver.getAllInsightIntentInfo<sup>20+<sup>
349
350getAllInsightIntentInfo(intentFlags: number): Promise<Array\<[InsightIntentInfo](#insightintentinfo20)>>
351
352Obtains the information about all intents on the current device. This API uses a promise to return the result.
353
354**Model restriction**: This API can be used only in the stage model.
355
356**System API**: This is a system API.
357
358**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
359
360**System capability**: SystemCapability.Ability.AbilityRuntime.Core
361
362**Parameters**
363
364  | Name| Type| Mandatory| Description|
365  | -------- | -------- | -------- | -------- |
366  | intentFlags | number | Yes| Flag of the intent information ([InsightIntentInfo](#insightintentinfo20)). It is used to query full or brief intent information. For details, see [GetInsightIntentFlag](#getinsightintentflag20).|
367
368**Return value**
369
370| Type| Description|
371| -------- | -------- |
372| Promise<Array\<[InsightIntentInfo](#insightintentinfo20)>> | Promise used to return an array holding InsightIntentInfo objects.|
373
374**Error codes**
375
376For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
377
378| ID| Error Message|
379| -------- | -------- |
380| 201      | Permission denied. |
381| 202      | Not system application. |
382| 16000050 | Internal error. |
383
384**Example**
385
386```ts
387  import { insightIntentDriver } from '@kit.AbilityKit';
388  import { BusinessError } from '@kit.BasicServicesKit';
389  import { hilog } from '@kit.PerformanceAnalysisKit';
390
391  async function getInfos() {
392    try {
393      insightIntentDriver.getAllInsightIntentInfo(insightIntentDriver.GetInsightIntentFlag.GET_FULL_INSIGHT_INTENT | insightIntentDriver.GetInsightIntentFlag.GET_ENTITY_INFO).then((data) => {
394        hilog.info(0x0000, 'testTag', 'getAllInsightIntentInfo return %{public}s', JSON.stringify(data));
395      }).catch((err: BusinessError) => {
396        hilog.info(0x0000, 'testTag', 'getAllInsightIntentInfo errCode: %{public}d', err.code);
397        hilog.info(0x0000, 'testTag', 'getAllInsightIntentInfo errMessage: %{public}s', err.message);
398      });
399    } catch (error) {
400      hilog.error(0x0000, 'testTag', 'getAllInsightIntentInfo error caught %{public}s', JSON.stringify(error));
401    }
402  }
403```
404
405## insightIntentDriver.getInsightIntentInfoByBundleName<sup>20+<sup>
406
407getInsightIntentInfoByBundleName(bundleName: string, intentFlags: number): Promise<Array\<[InsightIntentInfo](#insightintentinfo20)>>
408
409Obtains the intent information on the current device based on the given bundle name. This API uses a promise to return the result.
410
411**Model restriction**: This API can be used only in the stage model.
412
413**System API**: This is a system API.
414
415**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
416
417**System capability**: SystemCapability.Ability.AbilityRuntime.Core
418
419**Parameters**
420
421  | Name| Type| Mandatory| Description|
422  | -------- | -------- | -------- | -------- |
423  | bundleName | string | Yes| Bundle name of the application.<br>**NOTE**<br> If the bundle name does not exist, an empty array is returned.|
424  | intentFlags | number | Yes| Flag of the intent information ([InsightIntentInfo](#insightintentinfo20)). It is used to query full or brief intent information. For details, see [GetInsightIntentFlag](#getinsightintentflag20).|
425
426**Return value**
427
428| Type| Description|
429| -------- | -------- |
430| Promise<Array\<[InsightIntentInfo](#insightintentinfo20)>> | Promise used to return an array holding InsightIntentInfo objects.|
431
432**Error codes**
433
434For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
435
436| ID| Error Message|
437| -------- | -------- |
438| 201      | Permission denied. |
439| 202      | Not system application. |
440| 16000050 | Internal error. |
441
442**Example**
443
444```ts
445  import { insightIntentDriver } from '@kit.AbilityKit';
446  import { BusinessError } from '@kit.BasicServicesKit';
447  import { hilog } from '@kit.PerformanceAnalysisKit';
448
449  async function getInfosByBundleName() {
450    try {
451      let bundleName = "com.example.intent"; // Use the actual bundle name.
452      insightIntentDriver.getInsightIntentInfoByBundleName(bundleName, insightIntentDriver.GetInsightIntentFlag.GET_FULL_INSIGHT_INTENT | insightIntentDriver.GetInsightIntentFlag.GET_ENTITY_INFO).then((data) => {
453        hilog.info(0x0000, 'testTag', 'getInsightIntentInfoByBundleName return %{public}s', JSON.stringify(data));
454      }).catch((err: BusinessError) => {
455        hilog.info(0x0000, 'testTag', 'getInsightIntentInfoByBundleName errCode: %{public}d', err.code);
456        hilog.info(0x0000, 'testTag', 'getInsightIntentInfoByBundleName errMessage: %{public}s', err.message);
457      });
458    } catch (error) {
459      hilog.error(0x0000, 'testTag', 'getInsightIntentInfoByBundleName error caught %{public}s', JSON.stringify(error));
460    }
461  }
462```
463
464## insightIntentDriver.getInsightIntentInfoByIntentName<sup>20+<sup>
465
466getInsightIntentInfoByIntentName(bundleName: string, moduleName: string, intentName: string, intentFlags: number): Promise<[InsightIntentInfo](#insightintentinfo20)>
467
468Obtains the intent information on the current device based on the bundle name, module name, and intent name. This API uses a promise to return the result.
469
470**Model restriction**: This API can be used only in the stage model.
471
472**System API**: This is a system API.
473
474**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
475
476**System capability**: SystemCapability.Ability.AbilityRuntime.Core
477
478**Parameters**
479
480  | Name| Type| Mandatory| Description|
481  | -------- | -------- | -------- | -------- |
482  | bundleName | string | Yes| Bundle name of the application.<br>**NOTE**<br> If the bundle name does not exist, an empty object is returned.|
483  | moduleName | string | Yes| Module name<br>**NOTE**<br> If the module name does not exist, an empty object is returned.|
484  | intentName | string | Yes| Intent name.<br>**NOTE**<br> If the intent name does not exist, an empty object is returned.|
485  | intentFlags | number | Yes| Flag of the intent information ([InsightIntentInfo](#insightintentinfo20)). It is used to query full or brief intent information. For details, see [GetInsightIntentFlag](#getinsightintentflag20).|
486
487**Return value**
488
489| Type| Description|
490| -------- | -------- |
491| Promise<[InsightIntentInfo](#insightintentinfo20)> | Promise used to return the InsightIntentInfo object.|
492
493**Error codes**
494
495For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
496
497| ID| Error Message|
498| -------- | -------- |
499| 201      | Permission denied. |
500| 202      | Not system application. |
501| 16000050 | Internal error. |
502
503**Example**
504
505```ts
506  import { insightIntentDriver } from '@kit.AbilityKit';
507  import { BusinessError } from '@kit.BasicServicesKit';
508  import { hilog } from '@kit.PerformanceAnalysisKit';
509
510  function getInfoByIntentName() {
511    try {
512      let bundleName = "com.example.intent"; // Use the actual bundle name.
513      let moduleName = "entry"; // Use the actual module name.
514      let intentName = "play"; // Use the actual intent name.
515      insightIntentDriver.getInsightIntentInfoByIntentName(
516        bundleName, moduleName, intentName, insightIntentDriver.GetInsightIntentFlag.GET_FULL_INSIGHT_INTENT | insightIntentDriver.GetInsightIntentFlag.GET_ENTITY_INFO)
517      .then((data) => {
518        hilog.info(0x0000, 'testTag', 'getInsightIntentInfoByIntentName return %{public}s', JSON.stringify(data));
519      }).catch((err: BusinessError) => {
520        hilog.info(0x0000, 'testTag', 'getInsightIntentInfoByIntentName errCode: %{public}d', err.code);
521        hilog.info(0x0000, 'testTag', 'getInsightIntentInfoByIntentName errMessage: %{public}s', err.message);
522      });
523    } catch (error) {
524      hilog.error(0x0000, 'testTag', 'getInsightIntentInfoByIntentName error caught %{public}s', JSON.stringify(error));
525    }
526  }
527```
528