1e41f4b71Sopenharmony_ci# @ohos.app.ability.InsightIntentExecutor (Base Class for InsightIntent Call Execution) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **InsightIntentExecutor** module provides the base class for InsightIntent call execution. Through this base class, you can access the InsightIntent framework on the device side. You need to implement the service logic to respond to InsightIntent calls. To access the InsightIntent framework, you need to declare the InsightIntent name and InsightIntent access mode in the InsightIntent configuration file. The system calls the InsightIntent based on the user interaction and InsightIntent configuration file and triggers the corresponding InsightIntent call execution callback. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 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. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the stage model. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Modules to Import 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci```ts 14e41f4b71Sopenharmony_ciimport { InsightIntentExecutor } from '@kit.AbilityKit'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## Properties 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci| Name| Type| Read-only| Optional| Description| 26e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- | 27e41f4b71Sopenharmony_ci| context | [InsightIntentContext](js-apis-app-ability-insightIntentContext.md) | No| No| InsightIntent call execution context.| 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci## InsightIntentExecutor.onExecuteInUIAbilityForegroundMode 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_cionExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>, pageLoader: window.WindowStage): 32e41f4b71Sopenharmony_ci insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult> 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ciCalled when the InsightIntent call displays a UIAbility in the foreground. Both synchronous calls and asynchronous calls using Promise are supported. 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model. 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci**Parameters** 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 45e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 46e41f4b71Sopenharmony_ci| name | string | Yes| InsightIntent name.| 47e41f4b71Sopenharmony_ci| param | Record<string, Object> | Yes| InsightIntent call parameter.| 48e41f4b71Sopenharmony_ci| pageLoader | [window.WindowStage](../apis-arkui/js-apis-window.md#windowstage9) | Yes| Page loader.| 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci**Return value** 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci| Type| Description| 53e41f4b71Sopenharmony_ci| -------- | -------- | 54e41f4b71Sopenharmony_ci| [insightIntent.ExecuteResult](js-apis-app-ability-insightIntent.md#executeresult) | InsightIntent call execution result.| 55e41f4b71Sopenharmony_ci| Promise<[insightIntent.ExecuteResult](js-apis-app-ability-insightIntent.md#executeresult)> | Promise used to return the InsightIntent call execution result.| 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci**Example** 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ciThe code snippet below shows the synchronous call that returns the InsightIntent call result: 60e41f4b71Sopenharmony_ci ```ts 61e41f4b71Sopenharmony_ci import { InsightIntentExecutor, insightIntent } from '@kit.AbilityKit'; 62e41f4b71Sopenharmony_ci import { window } from '@kit.ArkUI'; 63e41f4b71Sopenharmony_ci import { hilog } from '@kit.PerformanceAnalysisKit'; 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci export default class IntentExecutorImpl extends InsightIntentExecutor { 66e41f4b71Sopenharmony_ci onExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>, pageLoader: window.WindowStage): insightIntent.ExecuteResult { 67e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult; 68e41f4b71Sopenharmony_ci if (name !== 'SupportedInsightIntentName') { 69e41f4b71Sopenharmony_ci hilog.warn(0x0000, 'testTag', 'Unsupported insight intent %{public}s', name); 70e41f4b71Sopenharmony_ci result = { 71e41f4b71Sopenharmony_ci // decided by developer 72e41f4b71Sopenharmony_ci code: 404, 73e41f4b71Sopenharmony_ci result: { 74e41f4b71Sopenharmony_ci message: 'Unsupported insight intent.', 75e41f4b71Sopenharmony_ci } 76e41f4b71Sopenharmony_ci }; 77e41f4b71Sopenharmony_ci return result; 78e41f4b71Sopenharmony_ci } 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci // if developer need load content 81e41f4b71Sopenharmony_ci pageLoader.loadContent('pages/Index', (err, data) => { 82e41f4b71Sopenharmony_ci if (err.code) { 83e41f4b71Sopenharmony_ci hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); 84e41f4b71Sopenharmony_ci } else { 85e41f4b71Sopenharmony_ci hilog.info(0x0000, 'testTag', '%{public}s', 'Succeeded in loading the content'); 86e41f4b71Sopenharmony_ci } 87e41f4b71Sopenharmony_ci }); 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci result = { 90e41f4b71Sopenharmony_ci code: 0, 91e41f4b71Sopenharmony_ci result: { 92e41f4b71Sopenharmony_ci message: 'Execute insight intent succeed.', 93e41f4b71Sopenharmony_ci } 94e41f4b71Sopenharmony_ci }; 95e41f4b71Sopenharmony_ci return result; 96e41f4b71Sopenharmony_ci } 97e41f4b71Sopenharmony_ci } 98e41f4b71Sopenharmony_ci ``` 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ciThe code snippet below shows the promise-based asynchronous call that returns the InsightIntent call result: 101e41f4b71Sopenharmony_ci ```ts 102e41f4b71Sopenharmony_ci import { InsightIntentExecutor, insightIntent } from '@kit.AbilityKit'; 103e41f4b71Sopenharmony_ci import { window } from '@kit.ArkUI'; 104e41f4b71Sopenharmony_ci import { hilog } from '@kit.PerformanceAnalysisKit'; 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci async function executeInsightIntent(param: Record<string, Object>): Promise<insightIntent.ExecuteResult> { 107e41f4b71Sopenharmony_ci return new Promise((resolve, reject) => { 108e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult = { 109e41f4b71Sopenharmony_ci code: 0, 110e41f4b71Sopenharmony_ci result: { 111e41f4b71Sopenharmony_ci message: 'Execute insight intent succeed.', 112e41f4b71Sopenharmony_ci } 113e41f4b71Sopenharmony_ci }; 114e41f4b71Sopenharmony_ci resolve(result); 115e41f4b71Sopenharmony_ci }) 116e41f4b71Sopenharmony_ci } 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci export default class IntentExecutorImpl extends InsightIntentExecutor { 119e41f4b71Sopenharmony_ci async onExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> { 120e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult; 121e41f4b71Sopenharmony_ci if (name !== 'SupportedInsightIntentName') { 122e41f4b71Sopenharmony_ci hilog.warn(0x0000, 'testTag', 'Unsupported insight intent %{public}s', name); 123e41f4b71Sopenharmony_ci result = { 124e41f4b71Sopenharmony_ci // decided by developer 125e41f4b71Sopenharmony_ci code: 404, 126e41f4b71Sopenharmony_ci result: { 127e41f4b71Sopenharmony_ci message: 'Unsupported insight intent.', 128e41f4b71Sopenharmony_ci } 129e41f4b71Sopenharmony_ci }; 130e41f4b71Sopenharmony_ci return result; 131e41f4b71Sopenharmony_ci } 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci result = await executeInsightIntent(param); 134e41f4b71Sopenharmony_ci return result; 135e41f4b71Sopenharmony_ci } 136e41f4b71Sopenharmony_ci } 137e41f4b71Sopenharmony_ci ``` 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ci## InsightIntentExecutor.onExecuteInUIAbilityBackgroundMode 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_cionExecuteInUIAbilityBackgroundMode(name: string, param: Record<string, Object>): 142e41f4b71Sopenharmony_ci insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult> 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ciCalled when the InsightIntent call displays a UIAbility in the background. Both synchronous calls and asynchronous calls using Promise are supported. 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model. 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci**Parameters** 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 155e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 156e41f4b71Sopenharmony_ci| name | string | Yes| InsightIntent name.| 157e41f4b71Sopenharmony_ci| param | Record<string, Object> | Yes| InsightIntent call parameter.| 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ci**Return value** 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci| Type| Description| 162e41f4b71Sopenharmony_ci| -------- | -------- | 163e41f4b71Sopenharmony_ci| [insightIntent.ExecuteResult](js-apis-app-ability-insightIntent.md#executeresult) | InsightIntent call execution result.| 164e41f4b71Sopenharmony_ci| Promise<[insightIntent.ExecuteResult](js-apis-app-ability-insightIntent.md#executeresult)> | Promise used to return the InsightIntent call execution result.| 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci**Example** 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ciThe code snippet below shows the synchronous call that returns the InsightIntent call result: 169e41f4b71Sopenharmony_ci ```ts 170e41f4b71Sopenharmony_ci import { InsightIntentExecutor, insightIntent } from '@kit.AbilityKit'; 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_ci export default class IntentExecutorImpl extends InsightIntentExecutor { 173e41f4b71Sopenharmony_ci onExecuteInUIAbilityBackgroundMode(name: string, param: Record<string, Object>): insightIntent.ExecuteResult { 174e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult = { 175e41f4b71Sopenharmony_ci code: 0, 176e41f4b71Sopenharmony_ci result: { 177e41f4b71Sopenharmony_ci message: 'Execute insight intent succeed.', 178e41f4b71Sopenharmony_ci } 179e41f4b71Sopenharmony_ci }; 180e41f4b71Sopenharmony_ci return result; 181e41f4b71Sopenharmony_ci } 182e41f4b71Sopenharmony_ci } 183e41f4b71Sopenharmony_ci ``` 184e41f4b71Sopenharmony_ci 185e41f4b71Sopenharmony_ciThe code snippet below shows the promise-based asynchronous call that returns the InsightIntent call result: 186e41f4b71Sopenharmony_ci ```ts 187e41f4b71Sopenharmony_ci import { InsightIntentExecutor, insightIntent } from '@kit.AbilityKit'; 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ci async function executeInsightIntent(param: Record<string, Object>): Promise<insightIntent.ExecuteResult> { 190e41f4b71Sopenharmony_ci return new Promise((resolve, reject) => { 191e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult = { 192e41f4b71Sopenharmony_ci code: 0, 193e41f4b71Sopenharmony_ci result: { 194e41f4b71Sopenharmony_ci message: 'Execute insight intent succeed.', 195e41f4b71Sopenharmony_ci } 196e41f4b71Sopenharmony_ci }; 197e41f4b71Sopenharmony_ci resolve(result); 198e41f4b71Sopenharmony_ci }) 199e41f4b71Sopenharmony_ci } 200e41f4b71Sopenharmony_ci 201e41f4b71Sopenharmony_ci export default class IntentExecutorImpl extends InsightIntentExecutor { 202e41f4b71Sopenharmony_ci async onExecuteInUIAbilityBackgroundMode(name: string, param: Record<string, Object>): Promise<insightIntent.ExecuteResult> { 203e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult = await executeInsightIntent(param); 204e41f4b71Sopenharmony_ci return result; 205e41f4b71Sopenharmony_ci } 206e41f4b71Sopenharmony_ci } 207e41f4b71Sopenharmony_ci ``` 208e41f4b71Sopenharmony_ci 209e41f4b71Sopenharmony_ci## InsightIntentExecutor.onExecuteInUIExtensionAbility 210e41f4b71Sopenharmony_ci 211e41f4b71Sopenharmony_cionExecuteInUIExtensionAbility(name: string, param: Record<string, Object>, pageLoader: UIExtensionContentSession): 212e41f4b71Sopenharmony_ci insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult> 213e41f4b71Sopenharmony_ci 214e41f4b71Sopenharmony_ciCalled when the InsightIntent call starts a UIExtensionAbility. Both synchronous calls and asynchronous calls using Promise are supported. 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model. 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 219e41f4b71Sopenharmony_ci 220e41f4b71Sopenharmony_ci**Parameters** 221e41f4b71Sopenharmony_ci 222e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 223e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 224e41f4b71Sopenharmony_ci| name | string | Yes| InsightIntent name.| 225e41f4b71Sopenharmony_ci| param | Record<string, Object> | Yes| InsightIntent call parameter.| 226e41f4b71Sopenharmony_ci| pageLoader | [UIExtensionContentSession](js-apis-app-ability-uiExtensionContentSession.md) | Yes| Page loader.| 227e41f4b71Sopenharmony_ci 228e41f4b71Sopenharmony_ci**Return value** 229e41f4b71Sopenharmony_ci 230e41f4b71Sopenharmony_ci| Type| Description| 231e41f4b71Sopenharmony_ci| -------- | -------- | 232e41f4b71Sopenharmony_ci| [insightIntent.ExecuteResult](js-apis-app-ability-insightIntent.md#executeresult) | InsightIntent call execution result.| 233e41f4b71Sopenharmony_ci| Promise<[insightIntent.ExecuteResult](js-apis-app-ability-insightIntent.md#executeresult)> | Promise used to return the InsightIntent call execution result.| 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci**Example** 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ciThe code snippet below shows the synchronous call that returns the InsightIntent call result: 238e41f4b71Sopenharmony_ci ```ts 239e41f4b71Sopenharmony_ci import { InsightIntentExecutor, insightIntent, UIExtensionContentSession } from '@kit.AbilityKit'; 240e41f4b71Sopenharmony_ci import { hilog } from '@kit.PerformanceAnalysisKit'; 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ci export default class IntentExecutorImpl extends InsightIntentExecutor { 243e41f4b71Sopenharmony_ci onExecuteInUIExtensionAbility(name: string, param: Record<string, Object>, pageLoader: UIExtensionContentSession): insightIntent.ExecuteResult { 244e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult; 245e41f4b71Sopenharmony_ci if (name !== 'SupportedInsightIntentName') { 246e41f4b71Sopenharmony_ci hilog.warn(0x0000, 'testTag', 'Unsupported insight intent %{public}s', name); 247e41f4b71Sopenharmony_ci result = { 248e41f4b71Sopenharmony_ci // decided by developer 249e41f4b71Sopenharmony_ci code: 404, 250e41f4b71Sopenharmony_ci result: { 251e41f4b71Sopenharmony_ci message: 'Unsupported insight intent.', 252e41f4b71Sopenharmony_ci } 253e41f4b71Sopenharmony_ci }; 254e41f4b71Sopenharmony_ci return result; 255e41f4b71Sopenharmony_ci } 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_ci // if developer need load content 258e41f4b71Sopenharmony_ci pageLoader.loadContent('pages/Index'); 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci result = { 261e41f4b71Sopenharmony_ci code: 0, 262e41f4b71Sopenharmony_ci result: { 263e41f4b71Sopenharmony_ci message: 'Execute insight intent succeed.', 264e41f4b71Sopenharmony_ci } 265e41f4b71Sopenharmony_ci }; 266e41f4b71Sopenharmony_ci return result; 267e41f4b71Sopenharmony_ci } 268e41f4b71Sopenharmony_ci } 269e41f4b71Sopenharmony_ci ``` 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ciThe code snippet below shows the promise-based asynchronous call that returns the InsightIntent call result: 272e41f4b71Sopenharmony_ci ```ts 273e41f4b71Sopenharmony_ci import { InsightIntentExecutor, insightIntent, UIExtensionContentSession } from '@kit.AbilityKit'; 274e41f4b71Sopenharmony_ci import { hilog } from '@kit.PerformanceAnalysisKit'; 275e41f4b71Sopenharmony_ci 276e41f4b71Sopenharmony_ci async function executeInsightIntent(param: Record<string, Object>): Promise<insightIntent.ExecuteResult> { 277e41f4b71Sopenharmony_ci return new Promise((resolve, reject) => { 278e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult = { 279e41f4b71Sopenharmony_ci code: 0, 280e41f4b71Sopenharmony_ci result: { 281e41f4b71Sopenharmony_ci message: 'Execute insight intent succeed.', 282e41f4b71Sopenharmony_ci } 283e41f4b71Sopenharmony_ci }; 284e41f4b71Sopenharmony_ci resolve(result); 285e41f4b71Sopenharmony_ci }) 286e41f4b71Sopenharmony_ci } 287e41f4b71Sopenharmony_ci 288e41f4b71Sopenharmony_ci export default class IntentExecutorImpl extends InsightIntentExecutor { 289e41f4b71Sopenharmony_ci async onExecuteInUIExtensionAbility(name: string, param: Record<string, Object>, pageLoader: UIExtensionContentSession): Promise<insightIntent.ExecuteResult> { 290e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult; 291e41f4b71Sopenharmony_ci if (name !== 'SupportedInsightIntentName') { 292e41f4b71Sopenharmony_ci hilog.warn(0x0000, 'testTag', 'Unsupported insight intent %{public}s', name); 293e41f4b71Sopenharmony_ci result = { 294e41f4b71Sopenharmony_ci // decided by developer 295e41f4b71Sopenharmony_ci code: 404, 296e41f4b71Sopenharmony_ci result: { 297e41f4b71Sopenharmony_ci message: 'Unsupported insight intent.', 298e41f4b71Sopenharmony_ci } 299e41f4b71Sopenharmony_ci }; 300e41f4b71Sopenharmony_ci return result; 301e41f4b71Sopenharmony_ci } 302e41f4b71Sopenharmony_ci 303e41f4b71Sopenharmony_ci result = await executeInsightIntent(param); 304e41f4b71Sopenharmony_ci return result; 305e41f4b71Sopenharmony_ci } 306e41f4b71Sopenharmony_ci } 307e41f4b71Sopenharmony_ci ``` 308e41f4b71Sopenharmony_ci 309e41f4b71Sopenharmony_ci## InsightIntentExecutor.onExecuteInServiceExtensionAbility 310e41f4b71Sopenharmony_ci 311e41f4b71Sopenharmony_cionExecuteInServiceExtensionAbility(name: string, param: Record<string, Object>): 312e41f4b71Sopenharmony_ci insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult> 313e41f4b71Sopenharmony_ci 314e41f4b71Sopenharmony_ciCalled when the InsightIntent call starts a ServiceExtensionAbility. Both synchronous calls and asynchronous calls using Promise are supported. 315e41f4b71Sopenharmony_ci 316e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model. 317e41f4b71Sopenharmony_ci 318e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Core 319e41f4b71Sopenharmony_ci 320e41f4b71Sopenharmony_ci**Parameters** 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 323e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 324e41f4b71Sopenharmony_ci| name | string | Yes| InsightIntent name.| 325e41f4b71Sopenharmony_ci| param | Record<string, Object> | Yes| InsightIntent call parameter.| 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci**Return value** 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci| Type| Description| 330e41f4b71Sopenharmony_ci| -------- | -------- | 331e41f4b71Sopenharmony_ci| [insightIntent.ExecuteResult](js-apis-app-ability-insightIntent.md#executeresult) | InsightIntent call execution result.| 332e41f4b71Sopenharmony_ci| Promise<[insightIntent.ExecuteResult](js-apis-app-ability-insightIntent.md#executeresult)> | Promise used to return the InsightIntent call execution result.| 333e41f4b71Sopenharmony_ci 334e41f4b71Sopenharmony_ci**Example** 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ciThe code snippet below shows the synchronous call that returns the InsightIntent call result: 337e41f4b71Sopenharmony_ci ```ts 338e41f4b71Sopenharmony_ci import { InsightIntentExecutor, insightIntent } from '@kit.AbilityKit'; 339e41f4b71Sopenharmony_ci import { hilog } from '@kit.PerformanceAnalysisKit'; 340e41f4b71Sopenharmony_ci 341e41f4b71Sopenharmony_ci export default class IntentExecutorImpl extends InsightIntentExecutor { 342e41f4b71Sopenharmony_ci onExecuteInServiceExtensionAbility(name: string, param: Record<string, Object>): insightIntent.ExecuteResult { 343e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult; 344e41f4b71Sopenharmony_ci if (name !== 'SupportedInsightIntentName') { 345e41f4b71Sopenharmony_ci hilog.warn(0x0000, 'testTag', 'Unsupported insight intent %{public}s', name); 346e41f4b71Sopenharmony_ci result = { 347e41f4b71Sopenharmony_ci // decided by developer 348e41f4b71Sopenharmony_ci code: 404, 349e41f4b71Sopenharmony_ci result: { 350e41f4b71Sopenharmony_ci message: 'Unsupported insight intent.', 351e41f4b71Sopenharmony_ci } 352e41f4b71Sopenharmony_ci }; 353e41f4b71Sopenharmony_ci return result; 354e41f4b71Sopenharmony_ci } 355e41f4b71Sopenharmony_ci 356e41f4b71Sopenharmony_ci result = { 357e41f4b71Sopenharmony_ci code: 0, 358e41f4b71Sopenharmony_ci result: { 359e41f4b71Sopenharmony_ci message: 'Execute insight intent succeed.', 360e41f4b71Sopenharmony_ci } 361e41f4b71Sopenharmony_ci }; 362e41f4b71Sopenharmony_ci return result; 363e41f4b71Sopenharmony_ci } 364e41f4b71Sopenharmony_ci } 365e41f4b71Sopenharmony_ci ``` 366e41f4b71Sopenharmony_ci 367e41f4b71Sopenharmony_ciThe code snippet below shows the promise-based asynchronous call that returns the InsightIntent call result: 368e41f4b71Sopenharmony_ci ```ts 369e41f4b71Sopenharmony_ci import { InsightIntentExecutor, insightIntent } from '@kit.AbilityKit'; 370e41f4b71Sopenharmony_ci import { hilog } from '@kit.PerformanceAnalysisKit'; 371e41f4b71Sopenharmony_ci 372e41f4b71Sopenharmony_ci async function executeInsightIntent(param: Record<string, Object>): Promise<insightIntent.ExecuteResult> { 373e41f4b71Sopenharmony_ci return new Promise((resolve, reject) => { 374e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult = { 375e41f4b71Sopenharmony_ci code: 0, 376e41f4b71Sopenharmony_ci result: { 377e41f4b71Sopenharmony_ci message: 'Execute insight intent succeed.', 378e41f4b71Sopenharmony_ci } 379e41f4b71Sopenharmony_ci }; 380e41f4b71Sopenharmony_ci resolve(result); 381e41f4b71Sopenharmony_ci }); 382e41f4b71Sopenharmony_ci } 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ci export default class IntentExecutorImpl extends InsightIntentExecutor { 385e41f4b71Sopenharmony_ci async onExecuteInServiceExtensionAbility(name: string, param: Record<string, Object>): Promise<insightIntent.ExecuteResult> { 386e41f4b71Sopenharmony_ci let result: insightIntent.ExecuteResult; 387e41f4b71Sopenharmony_ci if (name !== 'SupportedInsightIntentName') { 388e41f4b71Sopenharmony_ci hilog.warn(0x0000, 'testTag', 'Unsupported insight intent %{public}s', name); 389e41f4b71Sopenharmony_ci result = { 390e41f4b71Sopenharmony_ci // decided by developer 391e41f4b71Sopenharmony_ci code: 404, 392e41f4b71Sopenharmony_ci result: { 393e41f4b71Sopenharmony_ci message: 'Unsupported insight intent.', 394e41f4b71Sopenharmony_ci } 395e41f4b71Sopenharmony_ci }; 396e41f4b71Sopenharmony_ci return result; 397e41f4b71Sopenharmony_ci } 398e41f4b71Sopenharmony_ci 399e41f4b71Sopenharmony_ci result = await executeInsightIntent(param); 400e41f4b71Sopenharmony_ci return result; 401e41f4b71Sopenharmony_ci } 402e41f4b71Sopenharmony_ci } 403e41f4b71Sopenharmony_ci ``` 404