The file declares the APIs for obtaining the application information, including the bundle name, fingerprint information, and appId.
File to include: <bundle/native_interface_bundle.h>
Library: libbundle_ndk.z.so
System capability: SystemCapability.BundleManager.BundleFramework.Core
Since: 9
Related module: Native_Bundle
| Name | typedef Keyword | Description |
|---|---|---|
| OH_NativeBundle_ApplicationInfo | OH_NativeBundle_ApplicationInfo | Describes the application information, including the bundle name and fingerprint information. |
| OH_NativeBundle_ElementName | OH_NativeBundle_ElementName | Describes the elementName information. |
| OH_NativeBundle_Metadata | OH_NativeBundle_Metadata | Describes the metadata information. |
| OH_NativeBundle_ModuleMetadata | OH_NativeBundle_ModuleMetadata | Describes the metadata of a module. |
| Name | Description |
|---|---|
| OH_NativeBundle_ApplicationInfo OH_NativeBundle_GetCurrentApplicationInfo() | Obtains the current application information, including the bundle name and application fingerprint information. After using this interface, to avoid memory leak, you need to manually release the pointer of the field under the object returned by the interface. |
| char* OH_NativeBundle_GetAppId() | Obtains the appId of the current application. The appId is the unique identifier of an application and is determined by the bundle name and signature information of the application. After using this function, you must manually release the pointer returned to prevent memory leakage. |
| char* OH_NativeBundle_GetAppIdentifier() | Obtains the appIdentifier of the current application. The appIdentifier does not change throughout the application lifecycle, including version updates, certificate changes, public and private key changes, and application migration. After using this function, you must manually release the pointer returned to prevent memory leakage. |
| OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName() | Obtains the information about the mainElement of the current application entry, including the bundle name, module name, and component name. After using this interface, to avoid memory leak, you need to manually release the pointer of the field under the object returned by the interface. |
| char* OH_NativeBundle_GetCompatibleDeviceType() | Obtains the compatible device type of the current application. After using this function, you must manually release the pointer returned to prevent memory leakage. |
| bool OH_NativeBundle_IsDebugMode(bool* isDebugMode) | Checks whether the current application is in debug mode. |
| OH_NativeBundle_ModuleMetadata* OH_NativeBundle_GetModuleMetadata(size_t* size) | Obtains the module metadata array of the current application. After using this function, you must manually release the pointer returned to prevent memory leakage. |
| BundleManager_ErrorCode OH_NativeBundle_GetAbilityResourceInfo(char* fileType, OH_NativeBundle_AbilityResourceInfo** abilityResourceInfo, size_t* size) | Obtains a list of ability resource information that supports opening a specific file type. After using this function, you must call OH_AbilityResourceInfo_Destroy to release the pointer returned to prevent memory leakage. |
OH_NativeBundle_ApplicationInfo OH_NativeBundle_GetCurrentApplicationInfo()
Description
Obtains the current application information, including the bundle name and fingerprint information.
Since: 9
Returns
| Type | Description |
|---|---|
| OH_NativeBundle_ApplicationInfo | Pointer to the OH_NativeBundle_ApplicationInfo object. If the returned object is NULL, the creation fails. The possible cause is that the application address space is full, causing space allocation to fail. |
char* OH_NativeBundle_GetAppId()
Description
Obtains the appId of the current application. The appId is the unique identifier of an application and is determined by the bundle name and signature information of the application. After using this function, you must manually release the pointer returned to prevent memory leakage.
Since: 11
Returns
| Type | Description |
|---|---|
| char* | Returns a newly created string used to indicate the appId information. If the returned object is NULL, it indicates that creation failed. A possible cause of failure is that the application address space is full, causing space allocation failure. |
char* OH_NativeBundle_GetAppIdentifier()
Description
Obtains the appIdentifier of the current application. The appIdentifier does not change throughout the application lifecycle, including version updates, certificate changes, public and private key changes, and application migration. After using this function, you must manually release the pointer returned to prevent memory leakage.
Since: 11
Returns
| Type | Description |
|---|---|
| char* | Pointer to a new string that indicates the appIdentifier. If the returned object is NULL, the creation fails. The possible cause is that the application address space is full, causing space allocation to fail. |
OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName()
Description
Obtains the mainElement information of the current application, including the bundle name, module name, and ability name. After using this function, you must manually release the pointer returned to prevent memory leakage.
Since: 13
Returns
| Type | Description |
|---|---|
| OH_NativeBundle_ElementName | Returns a newly created OH_NativeBundle_ElementName object. If any field in the returned object is NULL, it indicates that creation failed. A possible cause of failure is that the application address space is full, causing space allocation failure. |
char* OH_NativeBundle_GetCompatibleDeviceType()
Description
Obtains the compatible device type of the current application. It helps you optimize the layout and font size when distributing mobile applications to tablets or 2-in-1 devices. After using this function, you must manually release the pointer returned to prevent memory leakage.
Since: 14
Returns
| Type | Description |
|---|---|
| char* | Pointer to a new string that indicates the compatible device type. If the returned object is NULL, the creation fails. The possible cause is that the application address space is full, causing space allocation to fail. |
bool OH_NativeBundle_IsDebugMode(bool* isDebugMode)
Description
Checks whether the current application is in debug mode.
Since: 20
Parameters
| Name | Description |
|---|---|
| bool* isDebugMode | Pointer to the check result indicating whether the application is in debug mode. true if in debug mode, false otherwise. |
Returns
| Type | Description |
|---|---|
| bool | Operation result. true if the call is successful, false otherwise. |
OH_NativeBundle_ModuleMetadata* OH_NativeBundle_GetModuleMetadata(size_t* size)
Description
Obtains the module metadata array of the current application. After using this function, you must manually release the pointer returned to prevent memory leakage.
Since: 20
Parameters
| Name | Description |
|---|---|
| size_t* size | Pointer to the size of the module metadata array. |
Returns
| Type | Description |
|---|---|
| OH_NativeBundle_ModuleMetadata* | Returns the module metadata array. If the returned object is NULL, it indicates that the acquisition failed. The possible cause of failure is that the application address space is full, causing space allocation failure. |
BundleManager_ErrorCode OH_NativeBundle_GetAbilityResourceInfo(char* fileType, OH_NativeBundle_AbilityResourceInfo** abilityResourceInfo, size_t* size)
Description
Obtains a list of ability resource information that supports opening a specific file type. After using this function, you must call OH_AbilityResourceInfo_Destroy to release the pointer returned to prevent memory leakage.
Since: 21
Required permissions: ohos.permission.GET_ABILITY_INFO
Device behavior differences: This API can be properly called only on PCs/2-in-1 devices. If it is called on other device types, error code 201 is returned.
Parameters
| Name | Description |
|---|---|
| char* fileType | Specific file type to query. It is recommended to use the UTD type, for example, "general.plain-text" and "general.image". Currently, it is also compatible with the MIME type and file extension names, such as "text/xml" and ".png". For the mapping between file extensions and file types, see UTD preset list. Passing "*/*" is not supported. |
| OH_NativeBundle_AbilityResourceInfo** abilityResourceInfo | Double pointer to the list of ability resource information. |
| size_t* size | Pointer to the size of the ability resource information list. |
Returns
| Type | Description |
|---|---|
| BundleManager_ErrorCode | BUNDLE_MANAGER_ERROR_CODE_NO_ERROR: The operation is successful. BUNDLE_MANAGER_ERROR_CODE_PERMISSION_DENIED: The caller does not have the required permission. |