harmony 鸿蒙@ohos.bundle.launcherBundleManager (launcherBundleManager)
@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 鸿蒙AbilityAccessControl
harmony 鸿蒙OH_NativeBundle_ApplicationInfo
harmony 鸿蒙OH_NativeBundle_ElementName
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦