openharmony 鸿蒙 js-apis-launcherBundleManager

2025-06-12 浏览 (1)

@ohos.bundle.launcherBundleManager (launcherBundleManager)

The bundle.launcherBundleManager module providers APIs for the launcher application to obtain the launcher ability information.

NOTE

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.

Modules to Import

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

launcherBundleManager.getLauncherAbilityInfoSync18+

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

Obtains the launcher ability information based on the given bundle name and user ID. This API uses an asynchronous callback to return the result.

Required permissions: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED

System capability: SystemCapability.BundleManager.BundleFramework.Launcher

Parameters

NameTypeMandatoryDescription
bundleNamestringYesBundle name.
userIdnumberYesUser ID, which can be obtained by calling getOsAccountLocalId.

Returns

TypeDescription
Array<LauncherAbilityInfo>Array of the LauncherAbilityInfo objects obtained.

Error codes

For details about the error codes, see Universal Error Codes and Bundle Error Codes.

IDError Message
201Verify permission denied.
801Capability not support.
17700001The specified bundle name is not found.
17700004The specified user ID is not found.

Example

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

Defines the information about the launcher ability.

System capability: SystemCapability.BundleManager.BundleFramework.Launcher

TypeDescription
_LauncherAbilityInfoAbility information of the home screen application.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ability Kit

harmony 鸿蒙AbilityAccessControl

harmony 鸿蒙AbilityBase

harmony 鸿蒙AbilityBase_Element

harmony 鸿蒙AbilityRuntime

harmony 鸿蒙bundle

harmony 鸿蒙OH_NativeBundle_ApplicationInfo

harmony 鸿蒙OH_NativeBundle_ElementName

harmony 鸿蒙ability_access_control.h

harmony 鸿蒙ability_base_common.h

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