openharmony 鸿蒙 capi-ability-resource-info-h

2026-08-25 浏览 (1)

ability_resource_info.h

Overview

The file declares the APIs for obtaining the following ability resource information: bundle name, module name, ability name, icon, clone index, and whether the application is a default application.

File to include: <bundle/ability_resource_info.h>

Library: libbundle_ndk.z.so

System capability: SystemCapability.BundleManager.BundleFramework.Core

Since: 21

Related module: Native_Bundle

Summary

Structs

Nametypedef KeywordDescription
OH_NativeBundle_AbilityResourceInfoOH_NativeBundle_AbilityResourceInfoDescribes the ability resource information.

Functions

NameDescription
BundleManager_ErrorCode OH_NativeBundle_GetBundleName(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, char** bundleName)Obtains the bundle name of the ability. After using this function, you must manually release the pointer returned to prevent memory leakage.
BundleManager_ErrorCode OH_NativeBundle_GetModuleName(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, char** moduleName)Obtains the module name of the ability. After using this function, you must manually release the pointer returned to prevent memory leakage.
BundleManager_ErrorCode OH_NativeBundle_GetAbilityName(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, char** abilityName)Obtains the ability name. After using this function, you must manually release the pointer returned to prevent memory leakage.
BundleManager_ErrorCode OH_NativeBundle_GetDrawableDescriptor(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, ArkUI_DrawableDescriptor** drawableIcon)Obtains the DrawableDescriptor object of the ability icon resource. After using this function, you must manually call OH_AbilityResourceInfo_Destroy to release the pointer returned to prevent memory leakage.
BundleManager_ErrorCode OH_NativeBundle_GetLabel(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, char** label)Obtains the application name of the ability. After using this function, you must manually release the pointer returned to prevent memory leakage.
BundleManager_ErrorCode OH_NativeBundle_GetAppIndex(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, int* appIndex)Obtains the clone index of the ability.
BundleManager_ErrorCode OH_NativeBundle_CheckDefaultApp(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, bool* isDefault)Checks whether the application to which the ability belongs is a default application.
BundleManager_ErrorCode OH_AbilityResourceInfo_Destroy(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, size_t count)Releases memory allocated for ability resource information.
int OH_NativeBundle_GetSize()Obtains the size of a single OH_NativeBundle_AbilityResourceInfo struct.

Function Description

OH_NativeBundle_GetBundleName()

BundleManager_ErrorCode OH_NativeBundle_GetBundleName(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, char** bundleName)

Description

Obtains the bundle name of the ability. After using this function, you must manually release the pointer returned to prevent memory leakage.

Since: 21

Parameters

NameDescription
OH_NativeBundle_AbilityResourceInfo* abilityResourceInfoPointer to the ability resource information.
char** bundleNameDouble pointer to the bundle name.

Returns

TypeDescription
BundleManager_ErrorCodeOne of the following operation results:
BUNDLE_MANAGER_ERROR_CODE_NO_ERROR: The retrieval is successful.
BUNDLE_MANAGER_ERROR_CODE_PARAM_INVALID: The retrieval fails because the abilityResourceInfo parameter is nullptr.

OH_NativeBundle_GetModuleName()

BundleManager_ErrorCode OH_NativeBundle_GetModuleName(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, char** moduleName)

Description

Obtains the module name of the ability. After using this function, you must manually release the pointer returned to prevent memory leakage.

Since: 21

Parameters

NameDescription
OH_NativeBundle_AbilityResourceInfo* abilityResourceInfoPointer to the ability resource information.
char** moduleNameDouble pointer to the module name.

Returns

TypeDescription
BundleManager_ErrorCodeOne of the following operation results:
BUNDLE_MANAGER_ERROR_CODE_NO_ERROR: The retrieval is successful.
BUNDLE_MANAGER_ERROR_CODE_PARAM_INVALID: The retrieval fails because the abilityResourceInfo parameter is nullptr.

OH_NativeBundle_GetAbilityName()

BundleManager_ErrorCode OH_NativeBundle_GetAbilityName(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, char** abilityName)

Description

Obtains the ability name. After using this function, you must manually release the pointer returned to prevent memory leakage.

Since: 21

Parameters

NameDescription
OH_NativeBundle_AbilityResourceInfo* abilityResourceInfoPointer to the ability resource information.
char** abilityNameDouble pointer to the ability name.

Returns

TypeDescription
BundleManager_ErrorCodeOne of the following operation results:
BUNDLE_MANAGER_ERROR_CODE_NO_ERROR: The retrieval is successful.
BUNDLE_MANAGER_ERROR_CODE_PARAM_INVALID: The retrieval fails because the abilityResourceInfo parameter is nullptr.

OH_NativeBundle_GetDrawableDescriptor()

BundleManager_ErrorCode OH_NativeBundle_GetDrawableDescriptor(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, ArkUI_DrawableDescriptor** drawableIcon)

Description

Obtains the DrawableDescriptor object of the ability icon resource. After using this function, you must manually call OH_AbilityResourceInfo_Destroy to release the pointer returned to prevent memory leakage.

Since: 21

Parameters

NameDescription
OH_NativeBundle_AbilityResourceInfo* abilityResourceInfoPointer to the ability resource information.
ArkUI_DrawableDescriptor** drawableIconDouble pointer to the DrawableDescriptor object.

Returns

TypeDescription
BundleManager_ErrorCodeOne of the following operation results:
BUNDLE_MANAGER_ERROR_CODE_NO_ERROR: The retrieval is successful.
BUNDLE_MANAGER_ERROR_CODE_PARAM_INVALID: The retrieval fails because the abilityResourceInfo parameter is nullptr.

OH_NativeBundle_GetLabel()

BundleManager_ErrorCode OH_NativeBundle_GetLabel(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, char** label)

Description

Obtains the application name of the ability. After using this function, you must manually release the pointer returned to prevent memory leakage.

Since: 21

Parameters

NameDescription
OH_NativeBundle_AbilityResourceInfo* abilityResourceInfoPointer to the ability resource information.
char** labelDouble pointer to the application name.

Returns

TypeDescription
BundleManager_ErrorCodeOne of the following operation results:
BUNDLE_MANAGER_ERROR_CODE_NO_ERROR: The retrieval is successful.
BUNDLE_MANAGER_ERROR_CODE_PARAM_INVALID: The retrieval fails because the abilityResourceInfo parameter is nullptr.

OH_NativeBundle_GetAppIndex()

BundleManager_ErrorCode OH_NativeBundle_GetAppIndex(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, int* appIndex)

Description

Obtains the clone index of the ability.

Since: 21

Parameters

NameDescription
OH_NativeBundle_AbilityResourceInfo* abilityResourceInfoPointer to the ability resource information.
int* appIndexDouble pointer to the clone index.

Returns

TypeDescription
BundleManager_ErrorCodeOne of the following operation results:
BUNDLE_MANAGER_ERROR_CODE_NO_ERROR: The retrieval is successful.
BUNDLE_MANAGER_ERROR_CODE_PARAM_INVALID: The retrieval fails because the abilityResourceInfo parameter is nullptr.

OH_NativeBundle_CheckDefaultApp()

BundleManager_ErrorCode OH_NativeBundle_CheckDefaultApp(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, bool* isDefault)

Description

Checks whether the application to which the ability belongs is a default application.

Since: 21

Parameters

NameDescription
OH_NativeBundle_AbilityResourceInfo* abilityResourceInfoPointer to the ability resource information.
bool* isDefaultPointer to the check result for whether the application is a default application. A default application is the preferred application set by the user for a specific file type or operation. true if the application is a default application, false otherwise.

Returns

TypeDescription
BundleManager_ErrorCodeOne of the following operation results:
BUNDLE_MANAGER_ERROR_CODE_NO_ERROR: The query is successful.
BUNDLE_MANAGER_ERROR_CODE_PARAM_INVALID: The query fails because the abilityResourceInfo parameter is nullptr.

OH_AbilityResourceInfo_Destroy()

BundleManager_ErrorCode OH_AbilityResourceInfo_Destroy(OH_NativeBundle_AbilityResourceInfo* abilityResourceInfo, size_t count)

Description

Releases memory allocated for ability resource information.

Since: 21

Parameters

NameDescription
OH_NativeBundle_AbilityResourceInfo* abilityResourceInfoPointer to the ability resource information.
size_t countSize of the ability resource information array.

Returns

TypeDescription
BundleManager_ErrorCodeOne of the following operation results:
BUNDLE_MANAGER_ERROR_CODE_NO_ERROR: The release is successful.
BUNDLE_MANAGER_ERROR_CODE_PARAM_INVALID: The release fails because the abilityResourceInfo parameter is nullptr.

OH_NativeBundle_GetSize()

int OH_NativeBundle_GetSize()

Description

Obtains the size of a single OH_NativeBundle_AbilityResourceInfo struct.

Since: 21

Returns

TypeDescription
intSize of a single OH_NativeBundle_AbilityResourceInfo struct.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 js-apis-app-ability-appServiceExtensionAbility

openharmony 鸿蒙 js-apis-inner-wantAgent-triggerInfo-sys

openharmony 鸿蒙 js-apis-inner-wantAgent-wantAgentInfo-sys

openharmony 鸿蒙 js-apis-appControl-sys

openharmony 鸿蒙 js-apis-app-ability-environmentCallback

openharmony 鸿蒙 js-apis-inner-application-missionInfo-sys

openharmony 鸿蒙 js-apis-bundleManager-sharedBundleInfo-sys

openharmony 鸿蒙 js-apis-inner-application-continueMissionInfo-sys

openharmony 鸿蒙 js-apis-inner-application-appServiceExtensionContext

openharmony 鸿蒙 js-apis-bundleManager-businessAbilityInfo-sys

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