openharmony 鸿蒙 capi-ohresmgr-h

2026-08-25 浏览 (1)

ohresmgr.h

Overview

Provides native APIs for obtaining resources.

File to include: <resourcemanager/ohresmgr.h>

Library: libohresmgr.so

System capability: SystemCapability.Global.ResourceManager

Since: 12

Related module: resourcemanager

Summary

Callback

NameDescription
ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64(const NativeResourceManager *mgr, uint32_t resId, char **resultValue, uint64_t *resultLen, uint32_t density = 0)Obtains the Base64 code of the media resource with the specified screen density based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64Data(const NativeResourceManager *mgr, uint32_t resId, char **resultValue, uint64_t *resultLen, uint32_t density)Obtains the Base64 code of the media resource with the specified screen density based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64ByName(const NativeResourceManager *mgr, const char *resName, char **resultValue, uint64_t *resultLen, uint32_t density = 0)Obtains the Base64 code of the media resource with the specified screen density based on the specified resource name.
ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64DataByName(const NativeResourceManager *mgr, const char *resName, char **resultValue, uint64_t *resultLen, uint32_t density)Obtains the Base64 code of the media resource with the specified screen density based on the specified resource name.
ResourceManager_ErrorCode OH_ResourceManager_GetMedia(const NativeResourceManager *mgr, uint32_t resId, uint8_t **resultValue, uint64_t *resultLen, uint32_t density = 0)Obtains the content of the media resource with the specified screen density based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetMediaData(const NativeResourceManager *mgr, uint32_t resId, uint8_t **resultValue, uint64_t *resultLen, uint32_t density)Obtains the content of the media resource with the specified screen density based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetMediaByName(const NativeResourceManager *mgr, const char *resName, uint8_t **resultValue, uint64_t *resultLen, uint32_t density = 0)Obtains the content of the media resource with the specified screen density based on the specified resource name.
ResourceManager_ErrorCode OH_ResourceManager_GetMediaDataByName(const NativeResourceManager *mgr, const char *resName, uint8_t **resultValue, uint64_t *resultLen, uint32_t density)Obtains the content of the media resource with the specified screen density based on the specified resource name.
ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptor(const NativeResourceManager *mgr, uint32_t resId, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density = 0, uint32_t type = 0)Obtains the DrawableDescriptor object of the icon resource with the specified screen density based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorData(const NativeResourceManager *mgr, uint32_t resId, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density, uint32_t type)Obtains the DrawableDescriptor object of the icon resource with the specified screen density based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorByName(const NativeResourceManager *mgr, const char *resName, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density = 0, uint32_t type = 0)Obtains the DrawableDescriptor object of the icon resource with the specified screen density based on the specified resource name.
ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorDataByName(const NativeResourceManager *mgr, const char *resName, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density, uint32_t type)Obtains the DrawableDescriptor object of the icon resource with the specified screen density based on the specified resource name.
ResourceManager_ErrorCode OH_ResourceManager_GetSymbol(const NativeResourceManager *mgr, uint32_t resId, uint32_t *resultValue)Obtains a symbol resource based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetSymbolByName(const NativeResourceManager *mgr, const char *resName, uint32_t *resultValue)Obtains a symbol resource based on the specified resource name.
ResourceManager_ErrorCode OH_ResourceManager_GetLocales(const NativeResourceManager *mgr, char ***resultValue, uint32_t *resultLen, bool includeSystem = false)Obtains the language list. After using this API, you need to call OH_ResourceManager_ReleaseStringArray() to release the memory of locales.
ResourceManager_ErrorCode OH_ResourceManager_GetLocalesData(const NativeResourceManager *mgr, char ***resultValue, uint32_t *resultLen, bool includeSystem)Obtains the language list. After using this API, you need to call OH_ResourceManager_ReleaseStringArray() to release the memory of locales.
ResourceManager_ErrorCode OH_ResourceManager_GetConfiguration(const NativeResourceManager *mgr, ResourceManager_Configuration *configuration)Obtains the device configuration. After using this API, you need to call OH_ResourceManager_ReleaseConfiguration to release the memory. If the ResourceManager_Configuration object is created by using malloc, call free() to release the object. (It is deprecated in API version 20.)
ResourceManager_ErrorCode OH_ResourceManager_GetResourceConfiguration(const NativeResourceManager *mgr, ResourceManager_Configuration *configuration)Obtains the device configuration. After using this API, you need to call OH_ResourceManager_ReleaseConfiguration to release the memory. If the ResourceManager_Configuration object is created by using malloc, call free() to release the object.
ResourceManager_ErrorCode OH_ResourceManager_ReleaseConfiguration(ResourceManager_Configuration *configuration)Releases the memory requested by using OH_ResourceManager_GetConfiguration or OH_ResourceManager_GetResourceConfiguration.
ResourceManager_ErrorCode OH_ResourceManager_GetString(const NativeResourceManager *mgr, uint32_t resId, char **resultValue, ...)Obtains a string resource based on the specified resource ID. The obtain common string resources, use OH_ResourceManager_GetString(mgr, resId, resultValue). The obtain formatted string resources with the %d, %s, and %f placeholders, use OH_ResourceManager_GetString(mgr, resId, resultValue, 10, "format", 10.10). After using this API, you need to call free() to release the memory of the strings.
ResourceManager_ErrorCode OH_ResourceManager_GetStringByName(const NativeResourceManager *mgr, const char *resName, char **resultValue, ...)Obtains a string resource based on the specified resource name. The obtain common string resources, use OH_ResourceManager_GetString(mgr, resName, resultValue). The obtain formatted string resources with the %d, %s, and %f placeholders, use OH_ResourceManager_GetString(mgr, resName, resultValue, 10, "format", 10.10). After using this API, you need to call free() to release the memory of the strings.
ResourceManager_ErrorCode OH_ResourceManager_GetStringArray(const NativeResourceManager *mgr, uint32_t resId, char ***resultValue, uint32_t *resultLen)Obtains a string array based on the specified resource ID. After using this API, you need to call OH_ResourceManager_ReleaseStringArray() to release the memory of the string array.
ResourceManager_ErrorCode OH_ResourceManager_GetStringArrayByName(const NativeResourceManager *mgr, const char *resName, char ***resultValue, uint32_t *resultLen)Obtains a string array based on the specified resource name. After using this API, you need to call OH_ResourceManager_ReleaseStringArray() to release the memory of the string array.
ResourceManager_ErrorCode OH_ResourceManager_ReleaseStringArray(char ***resValue, uint32_t len)Releases the memory of the string array.
ResourceManager_ErrorCode OH_ResourceManager_GetPluralString(const NativeResourceManager *mgr, uint32_t resId, uint32_t num, char **resultValue)Obtains singular and plural strings based on the specified resource ID. After using this API, you need to call free() to release the memory of the strings. (It is deprecated in API version 18.)
ResourceManager_ErrorCode OH_ResourceManager_GetPluralStringByName(const NativeResourceManager *mgr, const char *resName, uint32_t num, char **resultValue)Obtains singular and plural strings based on the specified resource name. After using this API, you need to call free() to release the memory of the strings. (It is deprecated in API version 18.)
ResourceManager_ErrorCode OH_ResourceManager_GetIntPluralString(const NativeResourceManager *mgr, uint32_t resId, uint32_t num, char **resultValue, ...)Obtains singular and plural strings based on the specified resource ID. After using this API, you need to call free() to release the memory of the strings.
ResourceManager_ErrorCode OH_ResourceManager_GetDoublePluralString(const NativeResourceManager *mgr, uint32_t resId, double num, char **resultValue, ...)Obtains singular and plural strings based on the specified resource ID. After using this API, you need to call free() to release the memory of the strings.
ResourceManager_ErrorCode OH_ResourceManager_GetIntPluralStringByName(const NativeResourceManager *mgr, const char *resName, uint32_t num, char **resultValue, ...)Obtains singular and plural strings based on the specified resource name. After using this API, you need to call free() to release the memory of the strings.
ResourceManager_ErrorCode OH_ResourceManager_GetDoublePluralStringByName(const NativeResourceManager *mgr, const char *resName, double num, char **resultValue, ...)Obtains singular and plural strings based on the specified resource name. After using this API, you need to call free() to release the memory of the strings.
ResourceManager_ErrorCode OH_ResourceManager_GetColor(const NativeResourceManager *mgr, uint32_t resId, uint32_t *resultValue)Obtains a color value based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetColorByName(const NativeResourceManager *mgr, const char *resName, uint32_t *resultValue)Obtains a color value based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetInt(const NativeResourceManager *mgr, uint32_t resId, int *resultValue)Obtains an int value based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetIntByName(const NativeResourceManager *mgr, const char *resName, int *resultValue)Obtains an int value based on the specified resource name.
ResourceManager_ErrorCode OH_ResourceManager_GetFloat(const NativeResourceManager *mgr, uint32_t resId, float *resultValue)Obtains a float value based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetFloatByName(const NativeResourceManager *mgr, const char *resName, float *resultValue)Obtains a float value based on the specified resource name.
ResourceManager_ErrorCode OH_ResourceManager_GetBool(const NativeResourceManager *mgr, uint32_t resId, bool *resultValue)Obtains a bool value based on the specified resource ID.
ResourceManager_ErrorCode OH_ResourceManager_GetBoolByName(const NativeResourceManager *mgr, const char *resName, bool *resultValue)Obtains a bool value based on the specified resource name.
ResourceManager_ErrorCode OH_ResourceManager_AddResource(const NativeResourceManager *mgr, const char *path)Adds overlay resources when an application is running.
ResourceManager_ErrorCode OH_ResourceManager_RemoveResource(const NativeResourceManager *mgr, const char *path)Removes overlay resources when an application is running.

Function Description

OH_ResourceManager_GetMediaBase64()

ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64(const NativeResourceManager *mgr, uint32_t resId, char **resultValue, uint64_t *resultLen, uint32_t density = 0)

Description

Obtains the Base64 code of the media resource with the specified screen density based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used.
char **resultValueResult of writing resultValue.
uint64_t *resultLenLength of media written to resultLen.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetMediaBase64Data()

ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64Data(const NativeResourceManager *mgr, uint32_t resId, char **resultValue, uint64_t *resultLen, uint32_t density)

Description

Obtains the Base64 code of the media resource with the specified screen density based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
char **resultValueResult of writing resultValue.
uint64_t *resultLenLength of media written to resultLen.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used. If this parameter is not required, set it to 0.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetMediaBase64ByName()

ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64ByName(const NativeResourceManager *mgr, const char *resName, char **resultValue, uint64_t *resultLen, uint32_t density = 0)

Description

Obtains the Base64 code of the media resource with the specified screen density based on the specified resource name.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
char **resultValueResult of writing resultValue.
uint64_t *resultLenLength of media written to resultLen.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetMediaBase64DataByName()

ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64DataByName(const NativeResourceManager *mgr, const char *resName, char **resultValue, uint64_t *resultLen, uint32_t density)

Description

Obtains the Base64 code of the media resource with the specified screen density based on the specified resource name.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
char **resultValueResult of writing resultValue.
uint64_t *resultLenLength of media written to resultLen.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used. If this parameter is not required, set it to 0.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetMedia()

ResourceManager_ErrorCode OH_ResourceManager_GetMedia(const NativeResourceManager *mgr, uint32_t resId, uint8_t **resultValue, uint64_t *resultLen, uint32_t density = 0)

Description

Obtains the content of the media resource with the specified screen density based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used.
uint8_t **resultValueResult of writing resultValue.
uint64_t *resultLenLength of media written to resultLen.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetMediaData()

ResourceManager_ErrorCode OH_ResourceManager_GetMediaData(const NativeResourceManager *mgr, uint32_t resId, uint8_t **resultValue, uint64_t *resultLen, uint32_t density)

Description

Obtains the content of the media resource with the specified screen density based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
uint8_t **resultValueResult of writing resultValue.
uint64_t *resultLenLength of media written to resultLen.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used. If this parameter is not required, set it to 0.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetMediaByName()

ResourceManager_ErrorCode OH_ResourceManager_GetMediaByName(const NativeResourceManager *mgr, const char *resName, uint8_t **resultValue, uint64_t *resultLen, uint32_t density = 0)

Description

Obtains the content of the media resource with the specified screen density based on the specified resource name.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used.
uint8_t **resultValueResult of writing resultValue.
uint64_t *resultLenLength of media written to resultLen.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetMediaDataByName()

ResourceManager_ErrorCode OH_ResourceManager_GetMediaDataByName(const NativeResourceManager *mgr, const char *resName, uint8_t **resultValue, uint64_t *resultLen, uint32_t density)

Description

Obtains the content of the media resource with the specified screen density based on the specified resource name.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
uint8_t **resultValueResult of writing resultValue.
uint64_t *resultLenLength of media written to resultLen.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used. If this parameter is not required, set it to 0.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetDrawableDescriptor()

ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptor(const NativeResourceManager *mgr, uint32_t resId, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density = 0, uint32_t type = 0)

Description

Obtains the DrawableDescriptor object of the icon resource with the specified screen density based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_tResource ID.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used.
uint32_t typeIcon type. The value 0 indicates an application icon, and the value 1 indicates a theme icon.
ArkUI_DrawableDescriptor **drawableDescriptorResult of writing drawableDescriptor.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.

OH_ResourceManager_GetDrawableDescriptorData()

ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorData(const NativeResourceManager *mgr, uint32_t resId, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density, uint32_t type)

Description

Obtains the DrawableDescriptor object of the icon resource with the specified screen density based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
ArkUI_DrawableDescriptor **drawableDescriptorResult of writing drawableDescriptor.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used. If this parameter is not required, set it to 0.
uint32_t typeIcon type. This parameter is optional. The value 0 indicates an application icon, and the value 1 indicates a theme icon. If this parameter is not required, set it to 0.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.

OH_ResourceManager_GetDrawableDescriptorByName()

ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorByName(const NativeResourceManager *mgr, const char *resName, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density = 0, uint32_t type = 0)

Description

Obtains the DrawableDescriptor object of the icon resource with the specified screen density based on the specified resource name.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used.
uint32_t typeIcon type. This parameter is optional. The value 0 indicates an application icon, the value 1 indicates a theme icon, and the value 2 indicates a dynamic icon.
ArkUI_DrawableDescriptor **drawableDescriptorResult of writing drawableDescriptor.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.

OH_ResourceManager_GetDrawableDescriptorDataByName()

ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorDataByName(const NativeResourceManager *mgr, const char *resName, ArkUI_DrawableDescriptor **drawableDescriptor, uint32_t density, uint32_t type)

Description

Obtains the DrawableDescriptor object of the icon resource with the specified screen density based on the specified resource name.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
ArkUI_DrawableDescriptor **drawableDescriptorResult of writing drawableDescriptor.
uint32_t densityScreen density. This parameter is optional. For details about the value range, see ScreenDensity. The default value is 0, indicating that the current system screen density (in DPI) is used. If this parameter is not required, set it to 0.
uint32_t typeIcon type. This parameter is optional. The value 0 indicates an application icon, and the value 1 indicates a theme icon. If this parameter is not required, set it to 0.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.

OH_ResourceManager_GetSymbol()

ResourceManager_ErrorCode OH_ResourceManager_GetSymbol(const NativeResourceManager *mgr, uint32_t resId, uint32_t *resultValue)

Description

Obtains a symbol resource based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
uint32_t *resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.

OH_ResourceManager_GetSymbolByName()

ResourceManager_ErrorCode OH_ResourceManager_GetSymbolByName(const NativeResourceManager *mgr, const char *resName, uint32_t *resultValue)

Description

Obtains a symbol resource based on the specified resource name.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
uint32_t *resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.

OH_ResourceManager_GetLocales()

ResourceManager_ErrorCode OH_ResourceManager_GetLocales(const NativeResourceManager *mgr, char ***resultValue, uint32_t *resultLen, bool includeSystem = false)

Description

Obtains the language list. After using this API, you need to call OH_ResourceManager_ReleaseStringArray() to release the memory of locales.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
char ***resultValueResult of writing resultValue.
uint32_t *resultLenLength of locales written to resultLen.
bool includeSystemWhether system resources are included. The default value is false. This parameter does not take effect if only system resources are involved when you query the list of locales.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetLocalesData()

ResourceManager_ErrorCode OH_ResourceManager_GetLocalesData(const NativeResourceManager *mgr, char ***resultValue, uint32_t *resultLen, bool includeSystem)

Description

Obtains the language list. After using this API, you need to call OH_ResourceManager_ReleaseStringArray() to release the memory of locales.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
char ***resultValueResult of writing resultValue.
uint32_t *resultLenLength of locales written to resultLen.
bool includeSystemWhether system resources are included. If this parameter is not required, set it to false.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetConfiguration()

ResourceManager_ErrorCode OH_ResourceManager_GetConfiguration(const NativeResourceManager *mgr, ResourceManager_Configuration *configuration)

Description

Obtains the device configuration. After this API is used, call OH_ResourceManager_ReleaseConfiguration to release the memory. If the ResourceManager_Configuration object is created by using malloc, call free() to release the object.

Since: 12

Deprecated from: 20

Substitute: OH_ResourceManager_GetResourceConfiguration

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
ResourceManager_Configuration *configurationDevice configuration. The return value of configuration.screenDensity is the rounded value of the device's DPI divided by 160.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_SYSTEM_RES_MANAGER_GET_FAILED 9001009 - The attempt to access system resources fails.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetResourceConfiguration()

ResourceManager_ErrorCode OH_ResourceManager_GetResourceConfiguration(const NativeResourceManager *mgr, ResourceManager_Configuration *configuration)

Description

Obtains the device configuration. After this API is used, call OH_ResourceManager_ReleaseConfiguration to release the memory. If the ResourceManager_Configuration object is created by using malloc, call free() to release the object.

Since: 20

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
ResourceManager_Configuration *configurationDevice configuration. The return value of configuration.screenDensity is the device's DPI.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_SYSTEM_RES_MANAGER_GET_FAILED 9001009 - The attempt to access system resources fails.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_ReleaseConfiguration()

ResourceManager_ErrorCode OH_ResourceManager_ReleaseConfiguration(ResourceManager_Configuration *configuration)

Description

Releases the memory requested by using the OH_ResourceManager_GetConfiguration and OH_ResourceManager_GetResourceConfiguration methods.

Since: 12

Parameters

NameDescription
ResourceManager_Configuration *configurationConfiguration object whose memory needs to be released.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.

OH_ResourceManager_GetString()

ResourceManager_ErrorCode OH_ResourceManager_GetString(const NativeResourceManager *mgr, uint32_t resId, char **resultValue, ...)

Description

Obtains a string resource based on the specified resource ID. The obtain common string resources, use OH_ResourceManager_GetString(mgr, resId, resultValue). The obtain formatted string resources with the %d, %s, and %f placeholders, use OH_ResourceManager_GetString(mgr, resId, resultValue, 10, "format", 10.10). After using this API, you need to call free() to release the memory of the strings.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
char **resultValueResult of writing resultValue.
...Variable representing formatted string resources. Supported types include const char*, int, and float.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetStringByName()

ResourceManager_ErrorCode OH_ResourceManager_GetStringByName(const NativeResourceManager *mgr, const char *resName, char **resultValue, ...)

Description

Obtains a string resource based on the specified resource name. The obtain common string resources, use OH_ResourceManager_GetString(mgr, resName, resultValue). The obtain formatted string resources with the %d, %s, and %f placeholders, use OH_ResourceManager_GetString(mgr, resName, resultValue, 10, "format", 10.10). After using this API, you need to call free() to release the memory of the strings.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
char **resultValueResult of writing resultValue.
...Variable representing formatted string resources. Supported types include const char*, int, and float.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetStringArray()

ResourceManager_ErrorCode OH_ResourceManager_GetStringArray(const NativeResourceManager *mgr, uint32_t resId, char ***resultValue, uint32_t *resultLen)

Description

Obtains a string array based on the specified resource ID. After using this API, you need to call OH_ResourceManager_ReleaseStringArray() to release the memory of the string array.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
char ***resultValueResult of writing resultValue.
uint32_t *resultLenLength of StringArray written to resultLen.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetStringArrayByName()

ResourceManager_ErrorCode OH_ResourceManager_GetStringArrayByName(const NativeResourceManager *mgr, const char *resName, char ***resultValue, uint32_t *resultLen)

Description

Obtains a string array based on the specified resource name. After using this API, you need to call OH_ResourceManager_ReleaseStringArray() to release the memory of the string array.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
char ***resultValueResult of writing resultValue.
uint32_t *resultLenLength of StringArray written to resultLen.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_ReleaseStringArray()

ResourceManager_ErrorCode OH_ResourceManager_ReleaseStringArray(char ***resValue, uint32_t len)

Description

Releases the memory of the string array.

Since: 12

Parameters

NameDescription
char ***resValueString array whose memory needs to be released.
uint32_t lenLength of the string array.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.

OH_ResourceManager_GetPluralString()

ResourceManager_ErrorCode OH_ResourceManager_GetPluralString(const NativeResourceManager *mgr, uint32_t resId, uint32_t num, char **resultValue)

Description

Obtains singular and plural strings based on the specified resource ID. After using this API, you need to call free() to release the memory of the strings.

Since: 12

Deprecated from: 18

Substitute: OH_ResourceManager_GetIntPluralString

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
uint32_t numNumber.
char **resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetPluralStringByName()

ResourceManager_ErrorCode OH_ResourceManager_GetPluralStringByName(const NativeResourceManager *mgr, const char *resName, uint32_t num, char **resultValue)

Description

Obtains singular and plural strings based on the specified resource name. After using this API, you need to call free() to release the memory of the strings.

Since: 12

Deprecated from: 18

Substitute: OH_ResourceManager_GetIntPluralStringByName

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
uint32_t numNumber.
char **resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetIntPluralString()

ResourceManager_ErrorCode OH_ResourceManager_GetIntPluralString(const NativeResourceManager *mgr, uint32_t resId, uint32_t num, char **resultValue, ...)

Description

Obtains singular and plural strings based on the specified resource ID. After using this API, you need to call free() to release the memory of the strings.

Since: 18

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
uint32_t numQuantity value (an integer number). Its string representation is obtained based on the current language's plural rules.
char **resultValueResult of writing resultValue.
...Variable representing formatted string resources. Supported types include const char*, int, and float.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetDoublePluralString()

ResourceManager_ErrorCode OH_ResourceManager_GetDoublePluralString(const NativeResourceManager *mgr, uint32_t resId, double num, char **resultValue, ...)

Description

Obtains singular and plural strings based on the specified resource ID. After using this API, you need to call free() to release the memory of the strings.

Since: 18

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
double numQuantity value (a floating point number). Its string representation is obtained based on the current language's plural rules.
char **resultValueResult of writing resultValue.
...Variable representing formatted string resources. Supported types include const char*, int, and float.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetIntPluralStringByName()

ResourceManager_ErrorCode OH_ResourceManager_GetIntPluralStringByName(const NativeResourceManager *mgr, const char *resName, uint32_t num, char **resultValue, ...)

Description

Obtains singular and plural strings based on the specified resource name. After using this API, you need to call free() to release the memory of the strings.

Since: 18

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
uint32_t numQuantity value (an integer number). Its string representation is obtained based on the current language's plural rules.
char **resultValueResult of writing resultValue.
...Variable representing formatted string resources. Supported types include const char*, int, and float.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetDoublePluralStringByName()

ResourceManager_ErrorCode OH_ResourceManager_GetDoublePluralStringByName(const NativeResourceManager *mgr, const char *resName, double num, char **resultValue, ...)

Description

Obtains singular and plural strings based on the specified resource name. After using this API, you need to call free() to release the memory of the strings.

Since: 18

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
double numQuantity value (a floating point number). Its string representation is obtained based on the current language's plural rules.
char **resultValueResult of writing resultValue.
...Variable representing formatted string resources. Supported types include const char*, int, and float.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.
ERROR_CODE_OUT_OF_MEMORY 9001100 - A memory overflow occurs.

OH_ResourceManager_GetColor()

ResourceManager_ErrorCode OH_ResourceManager_GetColor(const NativeResourceManager *mgr, uint32_t resId, uint32_t *resultValue)

Description

Obtains a color value based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
uint32_t *resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.

OH_ResourceManager_GetColorByName()

ResourceManager_ErrorCode OH_ResourceManager_GetColorByName(const NativeResourceManager *mgr, const char *resName, uint32_t *resultValue)

Description

Obtains a color value based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
uint32_t *resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.

OH_ResourceManager_GetInt()

ResourceManager_ErrorCode OH_ResourceManager_GetInt(const NativeResourceManager *mgr, uint32_t resId, int *resultValue)

Description

Obtains an int value based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
int *resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.

OH_ResourceManager_GetIntByName()

ResourceManager_ErrorCode OH_ResourceManager_GetIntByName(const NativeResourceManager *mgr, const char *resName, int *resultValue)

Description

Obtains an int value based on the specified resource name.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
int *resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.

OH_ResourceManager_GetFloat()

ResourceManager_ErrorCode OH_ResourceManager_GetFloat(const NativeResourceManager *mgr, uint32_t resId, float *resultValue)

Description

Obtains a float value based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
float *resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.

OH_ResourceManager_GetFloatByName()

ResourceManager_ErrorCode OH_ResourceManager_GetFloatByName(const NativeResourceManager *mgr, const char *resName, float *resultValue)

Description

Obtains a float value based on the specified resource name.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
float *resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.

OH_ResourceManager_GetBool()

ResourceManager_ErrorCode OH_ResourceManager_GetBool(const NativeResourceManager *mgr, uint32_t resId, bool *resultValue)

Description

Obtains a bool value based on the specified resource ID.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
uint32_t resIdResource ID.
bool *resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_ID_NOT_FOUND 9001001 - The resource ID is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002 - No matching resource is found based on the resource ID.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.

OH_ResourceManager_GetBoolByName()

ResourceManager_ErrorCode OH_ResourceManager_GetBoolByName(const NativeResourceManager *mgr, const char *resName, bool *resultValue)

Description

Obtains a bool value based on the specified resource name.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *resNameResource name.
bool *resultValueResult of writing resultValue.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_RES_NAME_NOT_FOUND 9001003 - The resource name is invalid.
ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004 - No matching resource is found based on the resource name.
ERROR_CODE_RES_REF_TOO_MUCH 9001006 - The resource is cyclically referenced.

OH_ResourceManager_AddResource()

ResourceManager_ErrorCode OH_ResourceManager_AddResource(const NativeResourceManager *mgr, const char *path)

Description

Adds overlay resources when an application is running.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *pathResource path.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_OVERLAY_RES_PATH_INVALID 9001010 - The resource path is invalid.

OH_ResourceManager_RemoveResource()

ResourceManager_ErrorCode OH_ResourceManager_RemoveResource(const NativeResourceManager *mgr, const char *path)

Description

Removes overlay resources when an application is running.

Since: 12

Parameters

NameDescription
const NativeResourceManager *mgrPointer to NativeResourceManager. It is obtained by using OH_ResourceManager_InitNativeResourceManager.
const char *pathResource path.

Returns

TypeDescription
ResourceManager_ErrorCodeSUCCESS 0 - The operation is successful.
ERROR_CODE_INVALID_INPUT_PARAMETER 401 - The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed.
ERROR_CODE_OVERLAY_RES_PATH_INVALID 9001010 - The resource path is invalid.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-i18n-initialtimezonerule

openharmony 鸿蒙 capi-i18n-timezonerules

openharmony 鸿蒙 capi-resmgr-common-h

openharmony 鸿蒙 capi-i18n-annualtimezonerule

openharmony 鸿蒙 errorcode-font-manager

openharmony 鸿蒙 capi-raw-dir-h

openharmony 鸿蒙 capi-i18n-timezonerulequery

openharmony 鸿蒙 capi-errorcode-h

openharmony 鸿蒙 js-apis-resource-manager

openharmony 鸿蒙 js-apis-sendableResource

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