openharmony 鸿蒙 js-apis-launcherBundleManager

2025-06-12 浏览 (1)

@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

参数:

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

返回值:

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

错误码:

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

错误码ID错误信息
201Verify permission denied.
801Capability not support.
17700001The specified bundle name is not found.
17700004The 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

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/ziTcbV