From 849747c268ffedd65370c03f0c9886e9b1754aa7 Mon Sep 17 00:00:00 2001 From: zhuxiang Date: Tue, 6 Jun 2023 07:14:43 +0000 Subject: [PATCH] add getSystemResourceManager doc description Signed-off-by: zhuxiang --- .../apis/js-apis-resource-manager.md | 39 +++++++++++++++++++ .../errorcodes/errorcode-resource-manager.md | 20 +++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md index 638bea89a1..0c84617611 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @@ -151,6 +151,45 @@ getResourceManager(bundleName: string): Promise<ResourceManager> ``` +## resourceManager.getSystemResourceManager + +getSystemResourceManager(): ResourceManager + +获取系统资源管理对象,返回系统资源的ResourceManager对象。 + +**系统能力**:SystemCapability.Global.ResourceManager + +**返回值:** + +| 类型 | 说明 | +| ---------------------------------------- | ------------------ | +| Resourcemanager | 返回系统资源的管理对象 | + +**错误码:** + +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001009 | If application can't access system resource. | + +**示例:** + ```js +import resourceManager from '@ohos.resourceManager'; + +try { + let systemResourceManager = resourceManager.getSystemResourceManager(); + systemResourceManager.getStringValue($r('sys.string.ohos_lab_vibrate').id).then(value => { + let str = value; + }).catch(error => { + console.log("systemResourceManager getStringValue promise error is " + error); + }); +} catch (error) { + console.error(`systemResourceManager getStringValue failed, error code: ${error.code}, message: ${error.message}.`) +} + ``` + + ## Direction 用于表示设备屏幕方向。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md index b77e345cc9..29cea491d8 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-resource-manager.md @@ -158,4 +158,22 @@ resName获取的字符串资源格式化失败。 **处理步骤** -查看args参数类型与占位符的个数、类型是否一致。 \ No newline at end of file +查看args参数类型与占位符的个数、类型是否一致。 + +## 9001009 获取系统资源管理器失败 + +**错误信息** + +Get system resource manager failed. + +**错误描述** + +获取系统资源管理器失败。 + +**可能原因** + +系统资源没有加载到应用进程的沙箱路径。 + +**处理步骤** + +查看应用进程是否包含系统资源沙箱路径。 \ No newline at end of file -- GitLab