@ohos.bundle.launcherBundleManager (launcherBundleManager Module)

The module providers APIs for launcher applications (applications with icons on the home screen) 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.getLauncherAbilityInfoSync

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

Obtains the launcher ability information based on the given bundle name and user ID.

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.info("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}`);
}

LauncherAbilityInfo

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.

ShortcutInfo20+

type ShortcutInfo = _ShortcutInfo

Defines the shortcut information defined in the module.json5 file of the application.

System capability: SystemCapability.BundleManager.BundleFramework.Launcher

Type Description
_ShortcutInfo Shortcut information defined in the module.json5 file.

ShortcutWant20+

type ShortcutWant = _ShortcutWant

Defines the target wants defined in the shortcut configuration.

System capability: SystemCapability.BundleManager.BundleFramework.Launcher

Type Description
_ShortcutWant Target wants defined in the shortcut configuration.

ParameterItem20+

type ParameterItem = _ParameterItem

Defines the custom data in the shortcut configuration.

System capability: SystemCapability.BundleManager.BundleFramework.Launcher

Type Description
_ParameterItem Custom data in the shortcut configuration.