• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bundle.launcherBundleManager (launcherBundleManager)
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 launcher application to obtain the [launcher ability information](js-apis-bundleManager-launcherAbilityInfo.md).
10
11> **NOTE**
12>
13> The initial APIs of this module are supported since API version 18. Newly added APIs will be marked with a superscript to indicate their earliest API version.
14
15## Modules to Import
16
17```ts
18import { launcherBundleManager } from '@kit.AbilityKit';
19```
20
21## launcherBundleManager.getLauncherAbilityInfoSync
22
23getLauncherAbilityInfoSync(bundleName: string, userId: number) : Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)\>
24
25Obtains the launcher ability information based on the given bundle name and user ID. This API uses an asynchronous callback to return the result.
26
27**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
28
29**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher
30
31**Parameters**
32
33| Name    | Type  | Mandatory| Description        |
34| ---------- | ------ | ---- | -------------- |
35| bundleName | string | Yes  | Bundle name.|
36| userId     | number | Yes  | User ID, which can be obtained by calling [getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9).|
37
38**Returns**
39
40| Type                         | Description                                              |
41| ----------------------------- | -------------------------------------------------- |
42| Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)\> | Array of the LauncherAbilityInfo objects 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| 801 | Capability not support. |
52| 17700001 | The specified bundle name is not found.  |
53| 17700004 | The specified user ID is not found.       |
54
55**Example**
56
57```ts
58import { launcherBundleManager } from '@kit.AbilityKit';
59import { BusinessError } from '@kit.BasicServicesKit';
60
61try {
62    let data = launcherBundleManager.getLauncherAbilityInfoSync("com.example.demo", 100);
63    console.info("data is " + JSON.stringify(data));
64} catch (errData) {
65    let code = (errData as BusinessError).code;
66    let message = (errData as BusinessError).message;
67    console.error(`errData is errCode:${code}  message:${message}`);
68}
69```
70
71## LauncherAbilityInfo
72
73type LauncherAbilityInfo = _LauncherAbilityInfo
74
75Defines the information about the launcher ability.
76
77**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher
78
79| Type                                                        | Description          |
80| ------------------------------------------------------------ | -------------- |
81| [_LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) | Ability information of the home screen application.|
82
83## ShortcutInfo<sup>20+</sup>
84
85type ShortcutInfo = _ShortcutInfo
86
87Defines the shortcut information defined in the [module.json5](../../quick-start/module-configuration-file.md#shortcuts) file of the application.
88
89**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher
90
91| Type                                                        | Description          |
92| ------------------------------------------------------------ | -------------- |
93| [_ShortcutInfo](./js-apis-bundleManager-shortcutInfo.md#shortcutinfo-1) | Shortcut information defined in the **module.json5** file.|
94
95## ShortcutWant<sup>20+</sup>
96
97type ShortcutWant = _ShortcutWant
98
99Defines the target [wants](../../quick-start/module-configuration-file.md#wants) defined in the shortcut configuration.
100
101**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher
102
103| Type                                                        | Description          |
104| ------------------------------------------------------------ | -------------- |
105| [_ShortcutWant](./js-apis-bundleManager-shortcutInfo.md#shortcutwant) | Target [wants](../../quick-start/module-configuration-file.md#wants) defined in the shortcut configuration.|
106
107## ParameterItem<sup>20+</sup>
108
109type ParameterItem = _ParameterItem
110
111Defines the custom data in the shortcut configuration.
112
113**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher
114
115| Type                                                        | Description          |
116| ------------------------------------------------------------ | -------------- |
117| [_ParameterItem](./js-apis-bundleManager-shortcutInfo.md#parameteritem) | Custom data in the shortcut configuration.|
118