• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bundle.launcherBundleManager (launcherBundleManager模块)
2
3本模块支持launcher应用所需的查询能力,支持[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)信息的查询。
4
5> **说明:**
6>
7> 本模块首批接口从API version 18开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8
9## 导入模块
10
11```ts
12import { launcherBundleManager } from '@kit.AbilityKit';
13```
14
15## launcherBundleManager.getLauncherAbilityInfoSync<sup>18+</sup>
16
17getLauncherAbilityInfoSync(bundleName: string, userId: number) : Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)\>
18
19查询指定bundleName及用户的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)。
20
21**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
22
23**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher
24
25**参数:**
26
27| 参数名     | 类型   | 必填 | 说明         |
28| ---------- | ------ | ---- | -------------- |
29| bundleName | string | 是   | 应用Bundle名称。 |
30| userId     | number | 是   | 被查询的用户id。 |
31
32**返回值:**
33
34| 类型                          | 说明                                               |
35| ----------------------------- | -------------------------------------------------- |
36| Array\<[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)\> | Array形式返回bundle包含的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)信息。 |
37
38**错误码:**
39
40以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[ohos.bundle错误码](errorcode-bundle.md)。
41
42| 错误码ID | 错误信息                                 |
43| -------- | ---------------------------------------- |
44| 201 | Verify permission denied. |
45| 801 | Capability not support. |
46| 17700001 | The specified bundle name is not found.  |
47| 17700004 | The specified user ID is not found.       |
48
49**示例:**
50
51```ts
52import { launcherBundleManager } from '@kit.AbilityKit';
53import { BusinessError } from '@kit.BasicServicesKit';
54
55try {
56    let data = launcherBundleManager.getLauncherAbilityInfoSync("com.example.demo", 100);
57    console.log("data is " + JSON.stringify(data));
58} catch (errData) {
59    let code = (errData as BusinessError).code;
60    let message = (errData as BusinessError).message;
61    console.error(`errData is errCode:${code}  message:${message}`);
62}
63```
64
65## LauncherAbilityInfo<sup>18+</sup>
66
67type LauncherAbilityInfo = _LauncherAbilityInfo
68
69LauncherAbilityInfo信息。
70
71**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher
72
73| 类型                                                         | 说明           |
74| ------------------------------------------------------------ | -------------- |
75| [_LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) | 桌面应用的Ability信息。 |