harmony 鸿蒙@ohos.bundle.launcherBundleManager (launcherBundleManager模块)

  • 2025-06-12
  • 浏览 (3)

@ohos.bundle.launcherBundleManager (launcherBundleManager模块)

本模块支持launcher应用所需的查询能力,支持LauncherAbilityInfo信息的查询。

说明:

本模块首批接口从API version 18开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

导入模块

import { launcherBundleManager } from '@kit.AbilityKit';

launcherBundleManager.getLauncherAbilityInfoSync18+

getLauncherAbilityInfoSync(bundleName: string, userId: number) : Array<LauncherAbilityInfo>

查询指定bundleName及用户的LauncherAbilityInfo

需要权限: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

系统能力: SystemCapability.BundleManager.BundleFramework.Launcher

参数:

参数名 类型 必填 说明
bundleName string 应用Bundle名称。
userId number 被查询的用户ID,可以通过getOsAccountLocalId接口获取。

返回值:

类型 说明
Array<LauncherAbilityInfo> Array形式返回bundle包含的LauncherAbilityInfo信息。

错误码:

以下错误码的详细介绍请参见通用错误码ohos.bundle错误码

错误码ID 错误信息
201 Verify permission denied.
801 Capability not support.
17700001 The specified bundle name is not found.
17700004 The specified user ID is not found.

示例:

import { launcherBundleManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

try {
    let data = launcherBundleManager.getLauncherAbilityInfoSync("com.example.demo", 100);
    console.log("data is " + JSON.stringify(data));
} catch (errData) {
    let code = (errData as BusinessError).code;
    let message = (errData as BusinessError).message;
    console.error(`errData is errCode:${code}  message:${message}`);
}

LauncherAbilityInfo18+

type LauncherAbilityInfo = _LauncherAbilityInfo

LauncherAbilityInfo信息。

系统能力: SystemCapability.BundleManager.BundleFramework.Launcher

类型 说明
_LauncherAbilityInfo 桌面应用的Ability信息。

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ability Kit(程序框架服务)

harmony 鸿蒙AbilityBase

harmony 鸿蒙AbilityBase_Element

harmony 鸿蒙AbilityRuntime

harmony 鸿蒙bundle

harmony 鸿蒙OH_NativeBundle_ApplicationInfo

harmony 鸿蒙OH_NativeBundle_ElementName

harmony 鸿蒙ability_base_common.h

harmony 鸿蒙ability_runtime_common.h

harmony 鸿蒙application_context.h

0  赞