1# @ohos.bundle.launcherBundleManager (launcherBundleManager) (System API) 2<!--Kit: Ability Kit--> 3<!--Subsystem: BundleManager--> 4<!--Owner: @wanghang904--> 5<!--Designer: @hanfeng6--> 6<!--Tester: @kongjing2--> 7<!--Adviser: @Brilliantry_Rui--> 8 9The module providers APIs for the Home Screen application to obtain the [launcher ability information](js-apis-bundleManager-launcherAbilityInfo.md) and [shortcut information](js-apis-bundleManager-shortcutInfo.md). 10 11> **NOTE** 12> 13> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 14> 15> The APIs provided by this module are system APIs. 16 17## Modules to Import 18 19```ts 20import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; 21``` 22 23 24## launcherBundleManager.getLauncherAbilityInfo<sup>9+</sup> 25 26getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallback\<Array\<LauncherAbilityInfo\>\>) : void 27 28Obtains the [launcher ability information](js-apis-bundleManager-launcherAbilityInfo.md) based on the given bundle name and user ID. This API uses an asynchronous callback to return the result. 29 30**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 31 32**System API**: This is a system API. 33 34**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 35 36**Parameters** 37 38| Name | Type | Mandatory| Description | 39| ---------- | ------ | ---- | -------------- | 40| bundleName | string | Yes | Bundle name.| 41| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9).| 42| callback | AsyncCallback\<Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)\>\> | Yes| Callback used to return the LauncherAbilityInfo object obtained.| 43 44**Error codes** 45 46For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 47 48| ID| Error Message | 49| -------- | ---------------------------------------- | 50| 201 | Verify permission denied. | 51| 202 | Permission denied, non-system app called system api. | 52| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 53| 801 | Capability not support. | 54| 17700001 | The specified bundle name is not found. | 55| 17700004 | The specified user ID is not found. | 56 57**Example** 58 59```ts 60import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; 61import { BusinessError } from '@ohos.base'; 62 63try { 64 launcherBundleManager.getLauncherAbilityInfo('com.example.demo', 100, 65 (errData: BusinessError, data: launcherBundleManager.LauncherAbilityInfo[]) => { 66 if (errData !== null) { 67 console.error(`errData is errCode:${errData.code} message:${errData.message}`); 68 } else { 69 console.info('data is ' + JSON.stringify(data)); 70 } 71 }) 72} catch (errData) { 73 let code = (errData as BusinessError).code; 74 let message = (errData as BusinessError).message; 75 console.error(`errData is errCode:${code} message:${message}`); 76} 77``` 78 79## launcherBundleManager.getLauncherAbilityInfo<sup>9+</sup> 80 81getLauncherAbilityInfo(bundleName: string, userId: number) : Promise\<Array\<LauncherAbilityInfo\>\> 82 83Obtains the [launcher ability information](js-apis-bundleManager-launcherAbilityInfo.md) based on the given bundle name and user ID. This API uses a promise to return the result. 84 85**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 86 87**System API**: This is a system API. 88 89**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 90 91**Parameters** 92 93| Name | Type | Mandatory| Description | 94| ---------- | ------ | ---- | -------------- | 95| bundleName | string | Yes | Bundle name.| 96| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9).| 97 98**Return value** 99 100| Type | Description | 101| ----------------------------- | -------------------------------------------------- | 102| Promise\<Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)\>\> | Promise used to return the LauncherAbilityInfo object obtained.| 103 104**Error codes** 105 106For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 107 108| ID| Error Message | 109| -------- | ---------------------------------------- | 110| 201 | Verify permission denied. | 111| 202 | Permission denied, non-system app called system api. | 112| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 113| 801 | Capability not support. | 114| 17700001 | The specified bundle name is not found. | 115| 17700004 | The specified user ID is not found. | 116 117**Example** 118 119```ts 120import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; 121import { BusinessError } from '@ohos.base'; 122 123try { 124 launcherBundleManager.getLauncherAbilityInfo("com.example.demo", 100) 125 .then((data: launcherBundleManager.LauncherAbilityInfo[]) => { 126 console.info('data is ' + JSON.stringify(data)); 127 }).catch ((errData: BusinessError) => { 128 console.error(`errData is errCode:${errData.code} message:${errData.message}`); 129 }) 130} catch (errData) { 131 let code = (errData as BusinessError).code; 132 let message = (errData as BusinessError).message; 133 console.error(`errData is errCode:${code} message:${message}`); 134} 135``` 136 137## launcherBundleManager.getAllLauncherAbilityInfo<sup>9+</sup> 138 139getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback\<Array\<LauncherAbilityInfo\>\>) : void 140 141Obtains the [launcher ability information](js-apis-bundleManager-launcherAbilityInfo.md) of all applications based on the given user ID. This API uses an asynchronous callback to return the result. 142 143**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 144 145**System API**: This is a system API. 146 147**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 148 149**Parameters** 150 151| Name| Type | Mandatory| Description | 152| ------ | ------ | ---- | -------------- | 153| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9).| 154| callback | AsyncCallback\<Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)\>\> | Yes| Callback used to return the array of LauncherAbilityInfo objects obtained.| 155 156**Error codes** 157 158For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 159 160| ID| Error Message | 161| -------- | ---------------------------------------- | 162| 201 | Verify permission denied. | 163| 202 | Permission denied, non-system app called system api. | 164| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 165| 801 | Capability not support. | 166| 17700004 | The specified user ID is not found. | 167 168Example 169 170```ts 171import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; 172import { BusinessError } from '@ohos.base'; 173 174try { 175 launcherBundleManager.getAllLauncherAbilityInfo(100, 176 (errData: BusinessError, data: launcherBundleManager.LauncherAbilityInfo[]) => { 177 if (errData !== null) { 178 console.error(`errData is errCode:${errData.code} message:${errData.message}`); 179 } else { 180 console.info('data is ' + JSON.stringify(data)); 181 } 182 }); 183} catch (errData) { 184 let code = (errData as BusinessError).code; 185 let message = (errData as BusinessError).message; 186 console.error(`errData is errCode:${code} message:${message}`); 187} 188``` 189## launcherBundleManager.getAllLauncherAbilityInfo<sup>9+</sup> 190 191getAllLauncherAbilityInfo(userId: number) : Promise\<Array\<LauncherAbilityInfo\>\> 192 193Obtains the [launcher ability information](js-apis-bundleManager-launcherAbilityInfo.md) of all applications based on the given user ID. This API uses a promise to return the result. 194 195**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 196 197**System API**: This is a system API. 198 199**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 200 201**Parameters** 202 203| Name| Type | Mandatory| Description | 204| ------ | ------ | ---- | -------------- | 205| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9).| 206 207**Return value** 208 209| Type | Description | 210| ----------------------------- | ------------------------------------------------------ | 211| Promise\<Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)\>\> | Promise used to return the array of LauncherAbilityInfo objects obtained.| 212 213**Error codes** 214 215For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 216 217| ID| Error Message | 218| -------- | ---------------------------------------- | 219| 201 | Verify permission denied. | 220| 202 | Permission denied, non-system app called system api. | 221| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 222| 801 | Capability not support. | 223| 17700004 | The specified user ID is not found. | 224 225**Example** 226 227```ts 228import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; 229import { BusinessError } from '@ohos.base'; 230 231try { 232 launcherBundleManager.getAllLauncherAbilityInfo(100) 233 .then((data: launcherBundleManager.LauncherAbilityInfo[]) => { 234 console.info('data is ' + JSON.stringify(data)); 235 }).catch ((errData: BusinessError) => { 236 console.error(`errData is errCode:${errData.code} message:${errData.message}`); 237 }); 238} catch (errData) { 239 let code = (errData as BusinessError).code; 240 let message = (errData as BusinessError).message; 241 console.error(`errData is errCode:${code} message:${message}`); 242} 243``` 244 245## launcherBundleManager.getShortcutInfo<sup>9+</sup> 246 247getShortcutInfo(bundleName :string, callback: AsyncCallback\<Array\<ShortcutInfo\>\>) : void 248 249Obtains the [shortcut information](js-apis-bundleManager-shortcutInfo.md) of the current user based on the given bundle name of a main application. To obtain shortcut information about an application clone, use [getShortcutInfoByAppIndex](#launcherbundlemanagergetshortcutinfobyappindex20). 250 251No permission is required for obtaining the caller's own information. 252 253**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 254 255**System API**: This is a system API. 256 257**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 258 259**Parameters** 260 261| Name | Type | Mandatory| Description | 262| ---------- | ------ | ---- | -------------- | 263| bundleName | string | Yes | Bundle name.| 264| callback | AsyncCallback\<Array\<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)\>\> | Yes| Callback used to return the [ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) object obtained.| 265 266**Error codes** 267 268For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 269 270| ID| Error Message | 271| -------- | ---------------------------------------- | 272| 201 | Verify permission denied. | 273| 202 | Permission denied, non-system app called system api. | 274| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 275| 801 | Capability not support. | 276| 17700001 | The specified bundle name is not found. | 277 278**Example** 279 280```ts 281import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; 282import { BusinessError } from '@ohos.base'; 283 284try { 285 launcherBundleManager.getShortcutInfo("com.example.demo", 286 (errData: BusinessError, data: launcherBundleManager.ShortcutInfo[]) => { 287 if (errData !== null) { 288 console.error(`errData is errCode:${errData.code} message:${errData.message}`); 289 } else { 290 console.info('data is ' + JSON.stringify(data)); 291 } 292 }); 293} catch (errData) { 294 let code = (errData as BusinessError).code; 295 let message = (errData as BusinessError).message; 296 console.error(`errData is errCode:${code} message:${message}`); 297} 298``` 299 300## launcherBundleManager.getShortcutInfo<sup>9+</sup> 301 302getShortcutInfo(bundleName : string) : Promise\<Array\<ShortcutInfo\>\> 303 304Obtains the [shortcut information](js-apis-bundleManager-shortcutInfo.md) of the current user based on the given bundle name of a main application. To obtain shortcut information about an application clone, use [getShortcutInfoByAppIndex](#launcherbundlemanagergetshortcutinfobyappindex20). 305 306No permission is required for obtaining the caller's own information. 307 308**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 309 310**System API**: This is a system API. 311 312**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 313 314**Parameters** 315 316| Name | Type | Mandatory| Description | 317| ---------- | ------ | ---- | -------------- | 318| bundleName | string | Yes | Bundle name.| 319 320**Return value** 321 322| Type | Description | 323| ---------------------- | ----------------------------------------------- | 324| Promise\<Array\<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)\>\> | Promise used to return the [ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) object obtained.| 325 326**Error codes** 327 328For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 329 330| ID| Error Message | 331| -------- | ---------------------------------------- | 332| 201 | Verify permission denied. | 333| 202 | Permission denied, non-system app called system api. | 334| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 335| 801 | Capability not support. | 336| 17700001 | The specified bundle name is not found. | 337 338**Example** 339 340```ts 341import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; 342import { BusinessError } from '@ohos.base'; 343 344try { 345 launcherBundleManager.getShortcutInfo("com.example.demo") 346 .then((data: launcherBundleManager.ShortcutInfo[]) => { 347 console.info('data is ' + JSON.stringify(data)); 348 }).catch ((errData: BusinessError) => { 349 console.error(`errData is errCode:${errData.code} message:${errData.message}`); 350 }); 351} catch (errData) { 352 let code = (errData as BusinessError).code; 353 let message = (errData as BusinessError).message; 354 console.error(`errData is errCode:${code} message:${message}`); 355} 356``` 357 358## launcherBundleManager.getShortcutInfoSync<sup>10+</sup> 359 360getShortcutInfoSync(bundleName : string) : Array\<ShortcutInfo\> 361 362Obtains the [shortcut information](js-apis-bundleManager-shortcutInfo.md) of the current user based on the given bundle name of a main application. To obtain shortcut information about an application clone, use [getShortcutInfoByAppIndex](#launcherbundlemanagergetshortcutinfobyappindex20). 363 364No permission is required for obtaining the caller's own information. 365 366**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 367 368**System API**: This is a system API. 369 370**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 371 372**Parameters** 373 374| Name | Type | Mandatory| Description | 375| ---------- | ------ | ---- | -------------- | 376| bundleName | string | Yes | Bundle name.| 377 378**Return value** 379 380| Type | Description | 381| ---------------------- | ----------------------------------------------- | 382| Array\<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)\> | Array of the [ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) objects obtained.| 383 384**Error codes** 385 386For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 387 388| ID| Error Message | 389| -------- | ---------------------------------------- | 390| 201 | Verify permission denied. | 391| 202 | Permission denied, non-system app called system api. | 392| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 393| 801 | Capability not support. | 394| 17700001 | The specified bundle name is not found. | 395 396**Example** 397 398```ts 399import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; 400import { BusinessError } from '@ohos.base'; 401 402try { 403 let data = launcherBundleManager.getShortcutInfoSync("com.example.demo"); 404 console.info('data is ' + JSON.stringify(data)); 405} catch (errData) { 406 let code = (errData as BusinessError).code; 407 let message = (errData as BusinessError).message; 408 console.error(`errData is errCode:${code} message:${message}`); 409} 410``` 411 412## launcherBundleManager.getShortcutInfoSync<sup>13+</sup> 413 414getShortcutInfoSync(bundleName: string, userId: number) : Array\<ShortcutInfo\> 415 416Obtains the [shortcut information](js-apis-bundleManager-shortcutInfo.md) of the specified user based on the given bundle name of a main application. To obtain shortcut information about an application clone, use [getShortcutInfoByAppIndex](#launcherbundlemanagergetshortcutinfobyappindex20). 417 418No permission is required for obtaining the caller's own information. 419 420**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO 421 422**System API**: This is a system API. 423 424**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 425 426**Parameters** 427 428| Name | Type | Mandatory| Description | 429| ---------- | ------ | ---- | -------------- | 430| bundleName | string | Yes | Bundle name.| 431| userId | number | Yes | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9). | 432 433**Return value** 434 435| Type | Description | 436| ---------------------- | ----------------------------------------------- | 437| Array\<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)\> | Array of the [ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) objects obtained.| 438 439**Error codes** 440 441For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 442 443| ID| Error Message | 444| -------- | ---------------------------------------- | 445| 201 | Verify permission denied. | 446| 202 | Permission denied, non-system app called system api. | 447| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 448| 801 | Capability not support. | 449| 17700001 | The specified bundle name is not found. | 450| 17700004 | The specified user ID is not found. | 451 452**Example** 453 454```ts 455import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; 456import { BusinessError } from '@ohos.base'; 457 458try { 459 let data = launcherBundleManager.getShortcutInfoSync("com.example.demo", 100); 460 console.info('data is ' + JSON.stringify(data)); 461} catch (errData) { 462 let code = (errData as BusinessError).code; 463 let message = (errData as BusinessError).message; 464 console.error(`errData is errCode:${code} message:${message}`); 465} 466``` 467 468## launcherBundleManager.startShortcut<sup>12+</sup> 469 470startShortcut(shortcutInfo: ShortcutInfo, options?: StartOptions): Promise\<void\> 471 472Starts an ability based on the specified [shortcut information](js-apis-bundleManager-shortcutInfo.md). 473 474**Required permissions**: ohos.permission.START_SHORTCUT 475 476**System API**: This is a system API. 477 478**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 479 480**Parameters** 481 482| Name | Type | Mandatory| Description | 483| ------------ | ------ | ---- | -------------- | 484| shortcutInfo | [ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) | Yes | Shortcut information of the application.| 485| options | [StartOptions](js-apis-app-ability-startOptions-sys.md) | No | Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| 486 487**Return value** 488 489| Type | Description | 490| ---------------------------------------- | ------- | 491| Promise\<void> | Promise that returns no value.| 492 493**Error codes** 494 495For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 496 497| ID| Error Message | 498| -------- | ---------------------------------------- | 499| 201 | Verify permission denied. | 500| 202 | Permission denied, non-system app called system api. | 501| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 502| 801 | Capability not support. | 503| 17700065 | The ability specified by want in the ShortcutInfo struct cannot be started. | 504 505**Example** 506 507```ts 508import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; 509import { BusinessError } from '@ohos.base'; 510 511try { 512 let data : Array<launcherBundleManager.ShortcutInfo> = launcherBundleManager.getShortcutInfoSync("com.example.demo"); 513 console.info('data is ' + JSON.stringify(data)); 514 if (data) { 515 try { 516 launcherBundleManager.startShortcut(data[0]) 517 .then(() => { 518 console.info('startShortcut success'); 519 }).catch ((err: BusinessError) => { 520 console.error(`errData is errCode:${err.code} message:${err.message}`); 521 }); 522 } catch (error) { 523 let code = (error as BusinessError).code; 524 let message = (error as BusinessError).message; 525 console.error(`error is errCode:${code} message:${message}`); 526 } 527 } 528} catch (errData) { 529 let code = (errData as BusinessError).code; 530 let message = (errData as BusinessError).message; 531 console.error(`errData is errCode:${code} message:${message}`); 532} 533``` 534 535## launcherBundleManager.startShortcutWithReason<sup>20+</sup> 536 537startShortcutWithReason(shortcutInfo: ShortcutInfo, startReason: string, options?: StartOptions): Promise\<void\> 538 539Starts an ability based on the specified shortcut information, and carries the reason for the shortcut launch. This API uses a promise to return the result. 540 541The launched ability can obtain the launch reason through the **launchReasonMessage** field of [LaunchParam](js-apis-app-ability-abilityConstant.md#launchparam) and handle service logic accordingly. 542 543**Required permissions**: ohos.permission.START_SHORTCUT and ohos.permission.SET_LAUNCH_REASON_MESSAGE 544 545(If the caller has the ohos.permission.START_SHORTCUT permission but not the ohos.permission.SET_LAUNCH_REASON_MESSAGE permission, the ability can be started, but the shortcut launch reason carried is invalid.) 546 547**System API**: This is a system API. 548 549**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 550 551**Parameters** 552 553| Name | Type | Mandatory| Description | 554| ------------ | ------ | ---- | -------------- | 555| shortcutInfo | [ShortcutInfo](js-apis-bundle-ShortcutInfo.md) | Yes | Shortcut information of the application.| 556| startReason | string | Yes | Reason for launching the shortcut. The value can be [AbilityConstant.REASON_MESSAGE_DESKTOP_SHORTCUT](js-apis-app-ability-abilityConstant.md#constants), indicating a home screen shortcut launch.| 557| options | [StartOptions](js-apis-app-ability-startOptions-sys.md) | No | Parameters used to specify the window mode of the target ability.| 558 559**Return value** 560 561| Type | Description | 562| ---------------------------------------- | ------- | 563| Promise\<void> | Promise that returns no value.| 564 565**Error codes** 566 567For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 568 569| ID| Error Message | 570| -------- | ---------------------------------------- | 571| 201 | Verify permission denied. | 572| 202 | Permission denied, non-system app called system api. | 573| 801 | Capability not support. | 574| 17700065 | The specified shortcut want in shortcut info is not supported to be started. | 575 576**Example** 577 578```ts 579import { launcherBundleManager } from '@kit.AbilityKit'; 580import { BusinessError } from '@kit.BasicServicesKit'; 581import { AbilityConstant } from '@kit.AbilityKit'; 582 583try { 584 let data : Array<launcherBundleManager.ShortcutInfo> = launcherBundleManager.getShortcutInfoSync("com.example.myapplication"); 585 console.info('startShortcutWithReason data is ' + JSON.stringify(data)); 586 let startReason = AbilityConstant.REASON_MESSAGE_DESKTOP_SHORTCUT; 587 if (data) { 588 try { 589 launcherBundleManager.startShortcutWithReason(data[0], startReason) 590 .then(() => { 591 console.info('startShortcutWithReason success'); 592 }).catch ((err: BusinessError) => { 593 console.error(`startShortcutWithReason errData is errCode:${err.code} message:${err.message}`); 594 }); 595 } catch (error) { 596 let code = (error as BusinessError).code; 597 let message = (error as BusinessError).message; 598 console.error(`startShortcutWithReason error is errCode:${code} message:${message}`); 599 } 600 } 601} catch (errData) { 602 let code = (errData as BusinessError).code; 603 let message = (errData as BusinessError).message; 604 console.error(`startShortcutWithReason errData is errCode:${code} message:${message}`); 605} 606``` 607 608## launcherBundleManager.getShortcutInfoByAppIndex<sup>20+</sup> 609 610getShortcutInfoByAppIndex(bundleName: string, appIndex: number): Array\<ShortcutInfo\> 611 612Obtains the [shortcut information](js-apis-bundleManager-shortcutInfo.md) of the current user based on the index of an application clone. 613 614No permission is required for obtaining the caller's own information. 615 616**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 617 618**System API**: This is a system API. 619 620**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher 621 622**Parameters** 623 624| Name | Type | Mandatory| Description | 625| ---------- | ------ | ---- | -------------- | 626| bundleName | string | Yes | Bundle name.| 627| appIndex | number | Yes | Index of the application clone.| 628 629**Return value** 630 631| Type | Description | 632| ---------------------- | ----------------------------------------------- | 633| Array\<[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)\> | Array of the [ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) objects obtained.| 634 635**Error codes** 636 637For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 638 639| ID| Error Message | 640| -------- | ---------------------------------------- | 641| 201 | Verify permission denied. | 642| 202 | Permission denied, non-system app called system api. | 643| 801 | Capability not support. | 644| 17700001 | The specified bundle name is not found. | 645| 17700061 | The specified app index is invalid. | 646 647**Example** 648 649```ts 650import { launcherBundleManager } from '@kit.AbilityKit'; 651import { BusinessError } from '@kit.BasicServicesKit'; 652 653try { 654 let data = launcherBundleManager.getShortcutInfoByAppIndex("com.example.demo", 1); 655 console.info('getShortcutInfoByAppIndex successfully, data is ' + JSON.stringify(data)); 656} catch (errData) { 657 let code = (errData as BusinessError).code; 658 let message = (errData as BusinessError).message; 659 console.error(`Failed to getShortcutInfoByAppIndex. Code: ${code}, message: ${message}`); 660} 661``` 662