1# Resourcemanager 2 3 4## Overview 5 6Provides C APIs for obtaining resources. 7 8**Since**: 12 9 10 11## Summary 12 13 14### File 15 16| Name| Description| 17| -------- | -------- | 18| [ohresmgr.h](ohresmgr_8h.md) | Provides native APIs for obtaining resources.| 19| [resmgr_common.h](resmgr__common_8h.md) | Provides the enum types and structures for resource manager APIs.| 20 21 22### Enum 23 24| Name| Description| 25| -------- | -------- | 26| [ResourceManager_ErrorCode](#resourcemanager_errorcode) {<br>SUCCESS = 0, ERROR_CODE_INVALID_INPUT_PARAMETER = 401, ERROR_CODE_RES_ID_NOT_FOUND = 9001001, ERROR_CODE_RES_NOT_FOUND_BY_ID = 9001002,<br>ERROR_CODE_RES_NAME_NOT_FOUND = 9001003, ERROR_CODE_RES_NOT_FOUND_BY_NAME = 9001004, ERROR_CODE_RES_PATH_INVALID = 9001005, ERROR_CODE_RES_REF_TOO_MUCH = 9001006,<br>ERROR_CODE_RES_ID_FORMAT_ERROR = 9001007, ERROR_CODE_RES_NAME_FORMAT_ERROR = 9001008, ERROR_CODE_SYSTEM_RES_MANAGER_GET_FAILED = 9001009, ERROR_CODE_OVERLAY_RES_PATH_INVALID = 9001010,<br>ERROR_CODE_OUT_OF_MEMORY = 9001100<br>} | Enumerates resource manager error codes.| 27| [ScreenDensity](#screendensity) {<br>SCREEN_SDPI = 120, SCREEN_MDPI = 160, SCREEN_LDPI = 240, SCREEN_XLDPI = 320,<br>SCREEN_XXLDPI = 480, SCREEN_XXXLDPI = 640<br>} | Enumerates screen density types.| 28 29 30### Callback 31 32| Name| Description| 33| -------- | -------- | 34| [ResourceManager_ErrorCode](#resourcemanager_errorcode)[OH_ResourceManager_GetMediaBase64](#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.| 35| [ResourceManager_ErrorCode](#resourcemanager_errorcode)[OH_ResourceManager_GetMediaBase64ByName](#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.| 36| [ResourceManager_ErrorCode](#resourcemanager_errorcode)[OH_ResourceManager_GetMedia](#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.| 37| [ResourceManager_ErrorCode](#resourcemanager_errorcode)[OH_ResourceManager_GetMediaByName](#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.| 38| [ResourceManager_ErrorCode](#resourcemanager_errorcode)[OH_ResourceManager_GetDrawableDescriptor](#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.| 39| [ResourceManager_ErrorCode](#resourcemanager_errorcode)[OH_ResourceManager_GetDrawableDescriptorByName](#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.| 40 41 42## Enum Description 43 44 45### ResourceManager_ErrorCode 46 47``` 48enum ResourceManager_ErrorCode 49``` 50 51**Description** 52 53Enumerates resource manager error codes. 54 55**Since**: 12 56 57| Value| Description| 58| -------- | -------- | 59| SUCCESS | Success.| 60| ERROR_CODE_INVALID_INPUT_PARAMETER | Invalid input parameter.| 61| ERROR_CODE_RES_ID_NOT_FOUND | Invalid resource ID.| 62| ERROR_CODE_RES_NOT_FOUND_BY_ID | Invalid resource name.| 63| ERROR_CODE_RES_NAME_NOT_FOUND | No matching resource found based on the resource ID.| 64| ERROR_CODE_RES_NOT_FOUND_BY_NAME | No matching resource found based on the resource name.| 65| ERROR_CODE_RES_PATH_INVALID | Invalid relative path.| 66| ERROR_CODE_RES_REF_TOO_MUCH | Resource referenced cyclically.| 67| ERROR_CODE_RES_ID_FORMAT_ERROR | Failed to format the resource obtained based on the specified resource ID.| 68| ERROR_CODE_RES_NAME_FORMAT_ERROR | Failed to format the resource obtained based on the specified resource name.| 69| ERROR_CODE_SYSTEM_RES_MANAGER_GET_FAILED | Failed to access system resources.| 70| ERROR_CODE_OVERLAY_RES_PATH_INVALID | Invalid overlay path.| 71| ERROR_CODE_OUT_OF_MEMORY | Memory overflow.| 72 73 74### ScreenDensity 75 76``` 77enum ScreenDensity 78``` 79 80**Description** 81 82Enumerates screen density types. 83 84**Since**: 12 85 86| Value| Description| 87| -------- | -------- | 88| SCREEN_SDPI | Screen density with small-scale dots per inch (SDPI).| 89| SCREEN_MDPI | Screen density with medium-scale dots per inch (MDPI).| 90| SCREEN_LDPI | Screen density with large-scale dots per inch (LDPI).| 91| SCREEN_XLDPI | Screen density with extra-large-scale dots per inch (XLDPI).| 92| SCREEN_XXLDPI | Screen density with extra-extra-large-scale dots per inch (XXLDPI).| 93| SCREEN_XXXLDPI | Screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI).| 94 95 96## Function Description 97 98 99### OH_ResourceManager_GetDrawableDescriptor() 100 101``` 102ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptor (const NativeResourceManager * mgr, uint32_t resId, ArkUI_DrawableDescriptor ** drawableDescriptor, uint32_t density = 0, uint32_t type = 0 ) 103``` 104 105**Description** 106 107Obtains the **DrawableDescriptor** object of the icon resource with the specified screen density based on the specified resource ID. 108 109**Since**: 12 110 111**Parameters** 112 113| Name| Description| 114| -------- | -------- | 115| mgr | Pointer to **NativeResourceManager**. It is obtained by using the **OH_ResourceManager_InitNativeResourceManager** API.| 116| resId | Resource ID.| 117| density | Screen density. If the value of **enddensity** is **0**, the current system screen density is used.| 118| type | Icon type. The value **0** indicates an application icon, and the value **1** indicates a theme icon.| 119| drawableDescriptor | Result of writing **drawableDescriptor**.| 120 121**Returns** 122 123SUCCESS = 0: Operation succeeded. 124 125ERROR_CODE_INVALID_INPUT_PARAMETER 401: The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed. 126 127ERROR_CODE_RES_ID_NOT_FOUND 9001001: The resource ID is invalid. 128 129ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002: No matching resource is found based on the resource ID. 130 131 132### OH_ResourceManager_GetDrawableDescriptorByName() 133 134``` 135ResourceManager_ErrorCode OH_ResourceManager_GetDrawableDescriptorByName (const NativeResourceManager * mgr, const char * resName, ArkUI_DrawableDescriptor ** drawableDescriptor, uint32_t density = 0, uint32_t type = 0 ) 136``` 137 138Description 139 140Obtains the **DrawableDescriptor** object of the icon resource with the specified screen density based on the specified resource name. 141 142**Since**: 12 143 144**Parameters** 145 146| Name| Description| 147| -------- | -------- | 148| mgr | Pointer to **NativeResourceManager**. It is obtained by using the **OH_ResourceManager_InitNativeResourceManager** API.| 149| resName | Resource name.| 150| density | Screen density. If the value of **enddensity** is **0**, the current system screen density is used.| 151| type | Icon type. The value **0** indicates an application icon, the value **1** indicates a theme icon, and the value **2** indicates a dynamic icon.| 152| drawableDescriptor | Result of writing **drawableDescriptor**.| 153 154**Returns** 155 156SUCCESS = 0: Operation succeeded. 157 158ERROR_CODE_INVALID_INPUT_PARAMETER 401: The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed. 159 160ERROR_CODE_RES_NAME_NOT_FOUND 9001003: The resource name is invalid. 161 162ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004: No matching resource is found based on the resource name. 163 164 165### OH_ResourceManager_GetMedia() 166 167``` 168ResourceManager_ErrorCode OH_ResourceManager_GetMedia (const NativeResourceManager * mgr, uint32_t resId, uint8_t ** resultValue, uint64_t * resultLen, uint32_t density = 0 ) 169``` 170 171Description 172 173Obtains the content of the media resource with the specified screen density based on the specified resource ID. 174 175**Since**: 12 176 177**Parameters** 178 179| Name| Description| 180| -------- | -------- | 181| mgr | Pointer to **NativeResourceManager**. It is obtained by using the **OH_ResourceManager_InitNativeResourceManager** API.| 182| resId | Resource ID.| 183| density | Screen density. If the value of **enddensity** is **0**, the current system screen density is used.| 184| resultValue | Result of writing **resultValue**.| 185| resultLen | Length of media written to **resultLen**.| 186 187**Returns** 188 189SUCCESS = 0: Operation succeeded. 190 191ERROR_CODE_INVALID_INPUT_PARAMETER 401: The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed. 192 193ERROR_CODE_RES_ID_NOT_FOUND 9001001: The resource ID is invalid. 194 195ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002: No matching resource is found based on the resource ID. 196 197ERROR_CODE_OUT_OF_MEMORY 9001100: The memory overflows. 198 199 200### OH_ResourceManager_GetMediaBase64() 201 202``` 203ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64 (const NativeResourceManager * mgr, uint32_t resId, char ** resultValue, uint64_t * resultLen, uint32_t density = 0 ) 204``` 205 206Description 207 208Obtains the Base64 code of the media resource with the specified screen density based on the specified resource ID. 209 210**Since**: 12 211 212**Parameters** 213 214| Name| Description| 215| -------- | -------- | 216| mgr | Pointer to **NativeResourceManager**. It is obtained by using the **OH_ResourceManager_InitNativeResourceManager** API.| 217| resId | Resource ID.| 218| density | Screen density. If the value of **enddensity** is **0**, the current system screen density is used.| 219| resultValue | Result of writing **resultValue**.| 220| resultLen | Length of media written to **resultLen**.| 221 222**Returns** 223 224SUCCESS = 0: Operation succeeded. 225 226ERROR_CODE_INVALID_INPUT_PARAMETER 401: The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed. 227 228ERROR_CODE_RES_ID_NOT_FOUND 9001001: The resource ID is invalid. 229 230ERROR_CODE_RES_NOT_FOUND_BY_ID 9001002: No matching resource is found based on the resource ID. 231 232ERROR_CODE_OUT_OF_MEMORY 9001100: The memory overflows. 233 234 235### OH_ResourceManager_GetMediaBase64ByName() 236 237``` 238ResourceManager_ErrorCode OH_ResourceManager_GetMediaBase64ByName (const NativeResourceManager * mgr, const char * resName, char ** resultValue, uint64_t * resultLen, uint32_t density = 0 ) 239``` 240 241Description 242 243Obtains the Base64 code of the media resource with the specified screen density based on the specified resource name. 244 245**Since**: 12 246 247**Parameters** 248 249| Name| Description| 250| -------- | -------- | 251| mgr | Pointer to **NativeResourceManager**. It is obtained by using the **OH_ResourceManager_InitNativeResourceManager** API.| 252| resName | Resource name.| 253| density | Screen density. If the value of **enddensity** is **0**, the current system screen density is used.| 254| resultValue | Result of writing **resultValue**.| 255| resultLen | Length of media written to **resultLen**.| 256 257**Returns** 258 259SUCCESS = 0: Operation succeeded. 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: The memory overflows. 260 261 262### OH_ResourceManager_GetMediaByName() 263 264``` 265ResourceManager_ErrorCode OH_ResourceManager_GetMediaByName (const NativeResourceManager * mgr, const char * resName, uint8_t ** resultValue, uint64_t * resultLen, uint32_t density = 0 ) 266``` 267 268Description 269 270Obtains the content of the media resource with the specified screen density based on the specified resource name. 271 272**Since**: 12 273 274**Parameters** 275 276| Name| Description| 277| -------- | -------- | 278| mgr | Pointer to **NativeResourceManager**. It is obtained by using the **OH_ResourceManager_InitNativeResourceManager** API.| 279| resName | Resource name.| 280| density | Screen density. If the value of **enddensity** is **0**, the current system screen density is used.| 281| resultValue | Result of writing **resultValue**.| 282| resultLen | Length of media written to **resultLen**.| 283 284**Returns** 285 286SUCCESS = 0: Operation succeeded. 287 288ERROR_CODE_INVALID_INPUT_PARAMETER 401: The input parameter is invalid. Possible causes: 1. The parameter type is incorrect. 2. Parameter verification failed. 289 290ERROR_CODE_RES_NAME_NOT_FOUND 9001003: The resource name is invalid. 291 292ERROR_CODE_RES_NOT_FOUND_BY_NAME 9001004: No matching resource is found based on the resource name. 293 294ERROR_CODE_OUT_OF_MEMORY 9001100: The memory overflows. 295