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

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

@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

Name Type Mandatory Description
bundleName string Yes Bundle name.
userId number Yes User ID, which can be obtained by calling getOsAccountLocalId.

Returns

Type Description
Array<LauncherAbilityInfo> Array of the LauncherAbilityInfo objects obtained.

Error codes

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

ID Error Message
201 Verify permission denied.
801 Capability not support.
17700001 The specified bundle name is not found.
17700004 The 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

Type Description
_LauncherAbilityInfo Ability 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

0  赞