Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
17a12c0c
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
17a12c0c
编写于
7月 25, 2023
作者:
Z
zt147369
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
资源管理文档优化
Signed-off-by:
N
zt147369
<
zhangting201@huawei.com
>
上级
2910bdc3
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
253 addition
and
221 deletion
+253
-221
zh-cn/application-dev/reference/apis/js-apis-resource-manager.md
...pplication-dev/reference/apis/js-apis-resource-manager.md
+253
-221
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-resource-manager.md
浏览文件 @
17a12c0c
...
...
@@ -35,10 +35,10 @@ getResourceManager(callback: AsyncCallback<ResourceManager>): void
获取当前应用的资源管理对象,使用callback形式返回ResourceManager对象。
**模型约束**
:此接口仅可在FA模型下使用。
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在FA模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -52,7 +52,7 @@ getResourceManager(callback: AsyncCallback<ResourceManager>): void
console
.
log
(
"
error is
"
+
error
);
return
;
}
mgr
.
getString
(
0x1000000
,
(
error
,
value
)
=>
{
mgr
.
getString
Value
(
0x1000000
,
(
error
,
value
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error is
"
+
error
);
}
else
{
...
...
@@ -70,10 +70,10 @@ getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManage
获取指定应用的资源管理对象,使用callback形式返回ResourceManager对象。
**模型约束**
:此接口仅可在FA模型下使用。
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在FA模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -94,10 +94,10 @@ getResourceManager(): Promise<ResourceManager>
获取当前应用的资源管理对象,使用Promise形式返回ResourceManager对象。
**模型约束**
:此接口仅可在FA模型下使用。
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在FA模型下使用。
**返回值:**
| 类型 | 说明 |
...
...
@@ -107,7 +107,7 @@ getResourceManager(): Promise<ResourceManager>
**示例:**
```
js
resourceManager
.
getResourceManager
().
then
(
mgr
=>
{
mgr
.
getString
(
0x1000000
,
(
error
,
value
)
=>
{
mgr
.
getString
Value
(
0x1000000
,
(
error
,
value
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error is
"
+
error
);
}
else
{
...
...
@@ -127,10 +127,10 @@ getResourceManager(bundleName: string): Promise<ResourceManager>
获取指定应用的资源管理对象,使用Promise形式返回ResourceManager对象。
**模型约束**
:此接口仅可在FA模型下使用。
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在FA模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -185,7 +185,7 @@ try {
console
.
log
(
"
systemResourceManager getStringValue promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`systemResourceManager getStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`systemResourceManager getStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -247,16 +247,6 @@ try {
| direction |
[
Direction
](
#direction
)
| 是 | 否 | 当前设备屏幕方向 |
| locale | string | 是 | 否 | 当前系统语言 |
**示例:**
```
js
resourceManager
.
getResourceManager
((
error
,
mgr
)
=>
{
mgr
.
getConfiguration
((
error
,
value
)
=>
{
let
direction
=
value
.
direction
;
let
locale
=
value
.
locale
;
});
});
```
## DeviceCapability
...
...
@@ -271,16 +261,6 @@ resourceManager.getResourceManager((error, mgr) => {
| screenDensity |
[
ScreenDensity
](
#screendensity
)
| 是 | 否 | 当前设备屏幕密度 |
| deviceType |
[
DeviceType
](
#devicetype
)
| 是 | 否 | 当前设备类型 |
**示例:**
```
js
resourceManager
.
getResourceManager
((
error
,
mgr
)
=>
{
mgr
.
getDeviceCapability
((
error
,
value
)
=>
{
let
screenDensity
=
value
.
screenDensity
;
let
deviceType
=
value
.
deviceType
;
});
});
```
## RawFileDescriptor<sup>8+</sup>
...
...
@@ -357,7 +337,7 @@ getStringValue(resId: number, callback: AsyncCallback<string>): void
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -401,7 +381,7 @@ getStringValue(resId: number): Promise<string>
console
.
log
(
"
getStringValue promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -414,6 +394,8 @@ getStringValue(resource: Resource, callback: AsyncCallback<string>): void
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -447,7 +429,7 @@ getStringValue(resource: Resource, callback: AsyncCallback<string>): void
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -461,6 +443,8 @@ getStringValue(resource: Resource): Promise<string>
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -497,7 +481,7 @@ getStringValue(resource: Resource): Promise<string>
console
.
log
(
"
getStringValue promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`
callback getStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`
promise getStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
}
```
...
...
@@ -538,7 +522,7 @@ getStringArrayValue(resId: number, callback: AsyncCallback<Array<string>
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getStringArrayValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getStringArrayValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -582,7 +566,7 @@ getStringArrayValue(resId: number): Promise<Array<string>>
console
.
log
(
"
getStringArrayValue promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getStringArrayValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getStringArrayValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -594,6 +578,8 @@ getStringArrayValue(resource: Resource, callback: AsyncCallback<Array<stri
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -627,7 +613,7 @@ getStringArrayValue(resource: Resource, callback: AsyncCallback<Array<stri
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getStringArrayValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getStringArrayValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -639,6 +625,8 @@ getStringArrayValue(resource: Resource): Promise<Array<string>>
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -675,7 +663,7 @@ getStringArrayValue(resource: Resource): Promise<Array<string>>
console
.
log
(
"
getStringArray promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getStringArrayValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getStringArrayValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -714,7 +702,7 @@ getMediaContent(resId: number, callback: AsyncCallback<Uint8Array>): void
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -754,7 +742,7 @@ getMediaContent(resId: number, density: number, callback: AsyncCallback<Uint8
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -796,7 +784,7 @@ getMediaContent(resId: number): Promise<Uint8Array>
console
.
log
(
"
getMediaContent promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -839,7 +827,7 @@ getMediaContent(resId: number, density: number): Promise<Uint8Array>
console
.
error
(
`promise getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -851,6 +839,8 @@ getMediaContent(resource: Resource, callback: AsyncCallback<Uint8Array>):
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -883,7 +873,7 @@ getMediaContent(resource: Resource, callback: AsyncCallback<Uint8Array>):
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -895,6 +885,8 @@ getMediaContent(resource: Resource, density: number, callback: AsyncCallback<
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -928,7 +920,7 @@ getMediaContent(resource: Resource, density: number, callback: AsyncCallback<
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -940,6 +932,8 @@ getMediaContent(resource: Resource): Promise<Uint8Array>
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -975,7 +969,7 @@ getMediaContent(resource: Resource): Promise<Uint8Array>
console
.
log
(
"
getMediaContent promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -987,6 +981,8 @@ getMediaContent(resource: Resource, density: number): Promise<Uint8Array>
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -1023,7 +1019,7 @@ getMediaContent(resource: Resource, density: number): Promise<Uint8Array>
console
.
error
(
`promise getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -1062,7 +1058,7 @@ getMediaContentBase64(resId: number, callback: AsyncCallback<string>): voi
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -1102,7 +1098,7 @@ getMediaContentBase64(resId: number, density: number, callback: AsyncCallback<
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -1144,7 +1140,7 @@ getMediaContentBase64(resId: number): Promise<string>
console
.
log
(
"
getMediaContentBase64 promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -1187,7 +1183,7 @@ getMediaContentBase64(resId: number, density: number): Promise<string>
console
.
error
(
`promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -1199,6 +1195,8 @@ getMediaContentBase64(resource: Resource, callback: AsyncCallback<string>)
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -1231,7 +1229,7 @@ getMediaContentBase64(resource: Resource, callback: AsyncCallback<string>)
}
});
}
catch
(
error
)
{
console
.
error
(
`
promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`
callback getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
}
```
...
...
@@ -1243,6 +1241,8 @@ getMediaContentBase64(resource: Resource, density: number, callback: AsyncCallba
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -1270,13 +1270,13 @@ getMediaContentBase64(resource: Resource, density: number, callback: AsyncCallba
try
{
this
.
context
.
resourceManager
.
getMediaContentBase64
(
resource
,
120
,
(
error
,
value
)
=>
{
if
(
error
!=
null
)
{
console
.
error
(
`
promise
getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
console
.
error
(
`
callback
getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
}
else
{
let
media
=
value
;
}
});
}
catch
(
error
)
{
console
.
error
(
`
promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`
callback getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
}
```
...
...
@@ -1288,6 +1288,8 @@ getMediaContentBase64(resource: Resource): Promise<string>
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -1323,7 +1325,7 @@ getMediaContentBase64(resource: Resource): Promise<string>
console
.
log
(
"
getMediaContentBase64 promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -1335,6 +1337,8 @@ getMediaContentBase64(resource: Resource, density: number): Promise<string>
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -1371,7 +1375,7 @@ getMediaContentBase64(resource: Resource, density: number): Promise<string>
console
.
error
(
`promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaContentBase64 failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -1391,16 +1395,18 @@ getConfiguration(callback: AsyncCallback<Configuration>): void
**示例:**
```
ts
resourceManager
.
getResourceManager
((
error
,
mgr
)
=>
{
mg
r
.
getConfiguration
((
error
,
value
)
=>
{
try
{
this
.
context
.
resourceManage
r
.
getConfiguration
((
error
,
value
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error is
"
+
error
);
console
.
error
(
"
getConfiguration callback
error is
"
+
error
);
}
else
{
let
direction
=
value
.
direction
;
let
locale
=
value
.
locale
;
}
});
});
}
catch
(
error
)
{
console
.
error
(
"
getConfiguration callback error is
"
+
error
);
}
```
...
...
@@ -1420,14 +1426,16 @@ getConfiguration(): Promise<Configuration>
**示例:**
```
ts
resourceManager
.
getResourceManager
((
error
,
mgr
)
=>
{
mg
r
.
getConfiguration
().
then
(
value
=>
{
try
{
this
.
context
.
resourceManage
r
.
getConfiguration
().
then
(
value
=>
{
let
direction
=
value
.
direction
;
let
locale
=
value
.
locale
;
}).
catch
(
error
=>
{
console
.
log
(
"
getConfiguration promise error is
"
+
error
);
});
console
.
error
(
"
getConfiguration promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
"
getConfiguration promise error is
"
+
error
);
}
```
...
...
@@ -1447,16 +1455,18 @@ getDeviceCapability(callback: AsyncCallback<DeviceCapability>): void
**示例:**
```
ts
resourceManager
.
getResourceManager
((
error
,
mgr
)
=>
{
mg
r
.
getDeviceCapability
((
error
,
value
)
=>
{
try
{
this
.
context
.
resourceManage
r
.
getDeviceCapability
((
error
,
value
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error is
"
+
error
);
console
.
error
(
"
getDeviceCapability callback
error is
"
+
error
);
}
else
{
let
screenDensity
=
value
.
screenDensity
;
let
deviceType
=
value
.
deviceType
;
}
});
});
}
catch
(
error
)
{
console
.
error
(
"
getDeviceCapability callback error is
"
+
error
);
}
```
...
...
@@ -1476,17 +1486,18 @@ getDeviceCapability(): Promise<DeviceCapability>
**示例:**
```
ts
resourceManager
.
getResourceManager
((
error
,
mgr
)
=>
{
mg
r
.
getDeviceCapability
().
then
(
value
=>
{
try
{
this
.
context
.
resourceManage
r
.
getDeviceCapability
().
then
(
value
=>
{
let
screenDensity
=
value
.
screenDensity
;
let
deviceType
=
value
.
deviceType
;
}).
catch
(
error
=>
{
console
.
log
(
"
getDeviceCapability promise error is
"
+
error
);
});
console
.
error
(
"
getDeviceCapability promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
"
getDeviceCapability promise error is
"
+
error
);
}
```
### getPluralStringValue<sup>9+</sup>
getPluralStringValue(resId: number, num: number, callback: AsyncCallback
<
string
>
): void
...
...
@@ -1524,7 +1535,7 @@ getPluralStringValue(resId: number, num: number, callback: AsyncCallback<stri
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getPluralStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getPluralStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -1569,7 +1580,7 @@ getPluralStringValue(resId: number, num: number): Promise<string>
console
.
log
(
"
getPluralStringValue promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`
callback getPluralStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`
promise getPluralStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
}
```
...
...
@@ -1581,6 +1592,8 @@ getPluralStringValue(resource: Resource, num: number, callback: AsyncCallback<
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -1615,9 +1628,8 @@ getPluralStringValue(resource: Resource, num: number, callback: AsyncCallback<
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getPluralStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getPluralStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
### getPluralStringValue<sup>9+</sup>
...
...
@@ -1628,6 +1640,8 @@ getPluralStringValue(resource: Resource, num: number): Promise<string>
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -1665,7 +1679,7 @@ getPluralStringValue(resource: Resource, num: number): Promise<string>
console
.
log
(
"
getPluralStringValue promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`
callback getPluralStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`
promise getPluralStringValue failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
}
```
...
...
@@ -1704,9 +1718,8 @@ getRawFileContent(path: string, callback: AsyncCallback<Uint8Array>): void
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getRawFileContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getRawFileContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
### getRawFileContent<sup>9+</sup>
...
...
@@ -1746,7 +1759,7 @@ getRawFileContent(path: string): Promise<Uint8Array>
console
.
log
(
"
getRawFileContent promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getRawFileContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getRawFileContent failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -1787,8 +1800,8 @@ getRawFd(path: string, callback: AsyncCallback<RawFileDescriptor>): void
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getRawFd failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
}
;
console
.
error
(
`callback getRawFd failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
### getRawFd<sup>9+</sup>
...
...
@@ -1831,7 +1844,7 @@ getRawFd(path: string): Promise<RawFileDescriptor>
});
}
catch
(
error
)
{
console
.
error
(
`promise getRawFd failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
}
;
}
```
### getRawFileList<sup>10+</sup>
...
...
@@ -1862,15 +1875,14 @@ getRawFileList(path: string, callback: AsyncCallback<Array\<string\>>): vo
try
{
// 传入""表示获取rawfile根目录下的文件列表
this
.
context
.
resourceManager
.
getRawFileList
(
""
,
(
error
,
value
)
=>
{
if
(
error
!=
null
)
{
console
.
error
(
`callback getRawFileList failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getRawFileList failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
else
{
let
rawFile
=
value
;
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getRawFileList failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getRawFileList failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
### getRawFileList<sup>10+</sup>
...
...
@@ -1907,71 +1919,13 @@ getRawFileList(path: string): Promise<Array\<string\>>
this
.
context
.
resourceManager
.
getRawFileList
(
""
).
then
(
value
=>
{
let
rawFile
=
value
;
}).
catch
(
error
=>
{
console
.
error
(
`promise getRawFileList failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getRawFileList failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
});
}
catch
(
error
)
{
console
.
error
(
`promise getRawFileList failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getRawFileList failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
### closeRawFileDescriptor<sup>8+</sup>
closeRawFileDescriptor(path: string, callback: AsyncCallback
<
void
>
): void
用户关闭resources/rawfile目录下rawfile文件的descriptor,使用callback形式返回。
**系统能力**
:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ----------- |
| path | string | 是 | rawfile文件路径 |
| callback | AsyncCallback
<
void
>
| 是 | 异步回调 |
**示例:**
```
ts
resourceManager
.
getResourceManager
((
error
,
mgr
)
=>
{
mgr
.
closeRawFileDescriptor
(
"
test.xml
"
,
(
error
,
value
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error is
"
+
error
);
}
});
});
```
### closeRawFileDescriptor<sup>8+</sup>
closeRawFileDescriptor(path: string): Promise
<
void
>
用户关闭resources/rawfile目录下rawfile文件的descriptor,使用Promise形式返回。
**系统能力**
:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ----------- |
| path | string | 是 | rawfile文件路径 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---- |
| Promise
<
void
>
| 无返回值 |
**示例:**
```
ts
resourceManager
.
getResourceManager
((
error
,
mgr
)
=>
{
mgr
.
closeRawFileDescriptor
(
"
test.xml
"
).
then
(
value
=>
{
let
result
=
value
;
}).
catch
(
error
=>
{
console
.
log
(
"
closeRawFileDescriptor promise error is
"
+
error
);
});
});
```
### closeRawFd<sup>9+</sup>
closeRawFd(path: string, callback: AsyncCallback
<
void
>
): void
...
...
@@ -2004,7 +1958,7 @@ closeRawFd(path: string, callback: AsyncCallback<void>): void
}
});
}
catch
(
error
)
{
console
.
error
(
`callback closeRawFd failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback closeRawFd failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2046,7 +2000,7 @@ closeRawFd(path: string): Promise<void>
console
.
log
(
"
closeRawFd promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise closeRawFd failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise closeRawFd failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2060,9 +2014,11 @@ release()
**示例:**
```
ts
resourceManager
.
getResourceManager
((
error
,
mgr
)
=>
{
mgr
.
release
();
});
try
{
this
.
context
.
resourceManager
.
release
();
}
catch
(
error
)
{
console
.
error
(
"
release error is
"
+
error
);
}
```
### getStringByName<sup>9+</sup>
...
...
@@ -2101,9 +2057,8 @@ getStringByName(resName: string, callback: AsyncCallback<string>): void
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getStringByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getStringByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
### getStringByName<sup>9+</sup>
...
...
@@ -2145,7 +2100,7 @@ getStringByName(resName: string): Promise<string>
console
.
log
(
"
getStringByName promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getStringByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getStringByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2185,7 +2140,7 @@ getStringArrayByName(resName: string, callback: AsyncCallback<Array<string
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getStringArrayByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getStringArrayByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2228,7 +2183,7 @@ getStringArrayByName(resName: string): Promise<Array<string>>
console
.
log
(
"
getStringArrayByName promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getStringArrayByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getStringArrayByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2267,7 +2222,7 @@ getMediaByName(resName: string, callback: AsyncCallback<Uint8Array>): void
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getMediaByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getMediaByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2307,7 +2262,7 @@ getMediaByName(resName: string, density: number, callback: AsyncCallback<Uint
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getMediaByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getMediaByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2392,7 +2347,7 @@ getMediaByName(resName: string, density: number): Promise<Uint8Array>
console
.
error
(
`promise getMediaByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2431,7 +2386,7 @@ getMediaBase64ByName(resName: string, callback: AsyncCallback<string>): vo
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getMediaBase64ByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getMediaBase64ByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2471,7 +2426,7 @@ getMediaBase64ByName(resName: string, density: number, callback: AsyncCallback&l
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getMediaBase64ByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getMediaBase64ByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2513,7 +2468,7 @@ getMediaBase64ByName(resName: string): Promise<string>
console
.
log
(
"
getMediaBase64ByName promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaBase64ByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaBase64ByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2556,7 +2511,7 @@ getMediaBase64ByName(resName: string, density: number): Promise<string>
console
.
error
(
`promise getMediaBase64ByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getMediaBase64ByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getMediaBase64ByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2597,7 +2552,7 @@ getPluralStringByName(resName: string, num: number, callback: AsyncCallback<s
}
});
}
catch
(
error
)
{
console
.
error
(
`callback getPluralStringByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`callback getPluralStringByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2642,7 +2597,7 @@ getPluralStringByName(resName: string, num: number): Promise<string>
console
.
log
(
"
getPluralStringByName promise error is
"
+
error
);
});
}
catch
(
error
)
{
console
.
error
(
`promise getPluralStringByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`promise getPluralStringByName failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2681,7 +2636,7 @@ getStringSync(resId: number): string
try
{
this
.
context
.
resourceManager
.
getStringSync
(
$r
(
'
app.string.test
'
).
id
);
}
catch
(
error
)
{
console
.
error
(
`getStringSync failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`getStringSync failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2722,7 +2677,7 @@ getStringSync(resId: number, ...args: Array<string | number>): string
try
{
this
.
context
.
resourceManager
.
getStringSync
(
$r
(
'
app.string.test
'
).
id
,
"
format string
"
,
10
,
98.78
);
}
catch
(
error
)
{
console
.
error
(
`getStringSync failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`getStringSync failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2734,6 +2689,8 @@ getStringSync(resource: Resource): string
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -2766,7 +2723,7 @@ getStringSync(resource: Resource): string
try
{
this
.
context
.
resourceManager
.
getStringSync
(
resource
);
}
catch
(
error
)
{
console
.
error
(
`getStringSync failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`getStringSync failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2778,6 +2735,8 @@ getStringSync(resource: Resource, ...args: Array<string | number>): string
**系统能力**
:SystemCapability.Global.ResourceManager
**模型约束**
:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -2812,7 +2771,7 @@ getStringSync(resource: Resource, ...args: Array<string | number>): string
try
{
this
.
context
.
resourceManager
.
getStringSync
(
resource
,
"
format string
"
,
10
,
98.78
);
}
catch
(
error
)
{
console
.
error
(
`getStringSync failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
console
.
error
(
`getStringSync failed, error code:
${
error
.
code
}
, message:
${
error
.
message
}
.`
)
;
}
```
...
...
@@ -2851,7 +2810,7 @@ getStringByNameSync(resName: string): string
try {
this.context.resourceManager.getStringByNameSync("test");
} catch (error) {
console.error(
`getStringByNameSync failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getStringByNameSync failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -2892,7 +2851,7 @@ getStringByNameSync(resName: string, ...args: Array<string | number>): string
try {
this.context.resourceManager.getStringByNameSync("test", "format string", 10, 98.78);
} catch (error) {
console.error(
`getStringByNameSync failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getStringByNameSync failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -2931,7 +2890,7 @@ getBoolean(resId: number): boolean
try {
this.context.resourceManager.getBoolean($r('app.boolean.boolean_test').id);
} catch (error) {
console.error(
`getBoolean failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getBoolean failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
### getBoolean<sup>9+</sup>
...
...
@@ -2942,6 +2901,8 @@ getBoolean(resource: Resource): boolean
**系统能力**:SystemCapability.Global.ResourceManager
**模型约束**:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -2974,7 +2935,7 @@ getBoolean(resource: Resource): boolean
try {
this.context.resourceManager.getBoolean(resource);
} catch (error) {
console.error(
`getBoolean failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getBoolean failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3013,7 +2974,7 @@ getBooleanByName(resName: string): boolean
try {
this.context.resourceManager.getBooleanByName("boolean_test");
} catch (error) {
console.error(
`getBooleanByName failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getBooleanByName failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3052,13 +3013,13 @@ getNumber(resId: number): number
try {
this.context.resourceManager.getNumber($r('app.integer.integer_test').id); // integer对应返回的是原数值
} catch (error) {
console.error(
`getNumber failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getNumber failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
try {
this.context.resourceManager.getNumber($r('app.float.float_test').id); // float对应返回的是真实像素点值
} catch (error) {
console.error(
`getNumber failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getNumber failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3070,6 +3031,8 @@ getNumber(resource: Resource): number
**系统能力**:SystemCapability.Global.ResourceManager
**模型约束**:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -3102,7 +3065,7 @@ getNumber(resource: Resource): number
try {
this.context.resourceManager.getNumber(resource);// integer对应返回的是原数值, float对应返回的是真实像素点值
} catch (error) {
console.error(
`getNumber failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getNumber failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3141,13 +3104,13 @@ getNumberByName(resName: string): number
try {
this.context.resourceManager.getNumberByName("integer_test");
} catch (error) {
console.error(
`getNumberByName failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getNumberByName failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
try {
this.context.resourceManager.getNumberByName("float_test");
} catch (error) {
console.error(
`getNumberByName failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getNumberByName failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3186,12 +3149,12 @@ getDrawableDescriptor(resId: number, density?: number): DrawableDescriptor;
try {
this.context.resourceManager.getDrawableDescriptor($r('app.media.icon').id);
} catch (error) {
console.error(
`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
try {
this.context.resourceManager.getDrawableDescriptor($r('app.media.icon').id, 120);
} catch (error) {
console.error(
`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3203,6 +3166,8 @@ getDrawableDescriptor(resource: Resource, density?: number): DrawableDescriptor;
**系统能力**:SystemCapability.Global.ResourceManager
**模型约束**:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -3235,12 +3200,12 @@ getDrawableDescriptor(resource: Resource, density?: number): DrawableDescriptor;
try {
this.context.resourceManager.getDrawableDescriptor(resource);
} catch (error) {
console.error(
`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
try {
this.context.resourceManager.getDrawableDescriptor(resource, 120);
} catch (error) {
console.error(
`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getDrawableDescriptor failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3279,12 +3244,12 @@ getDrawableDescriptorByName(resName: string, density?: number): DrawableDescript
try {
this.context.resourceManager.getDrawableDescriptorByName('icon');
} catch (error) {
console.error(
`getDrawableDescriptor
failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getDrawableDescriptor
ByName failed, error code: ${error.code}, message: ${error.message}.`
);
}
try {
this.context.resourceManager.getDrawableDescriptorByName('icon', 120);
} catch (error) {
console.error(
`getDrawableDescriptor
failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getDrawableDescriptor
ByName failed, error code: ${error.code}, message: ${error.message}.`
);
}
```
...
...
@@ -3324,7 +3289,7 @@ getColor(resId: number, callback: AsyncCallback<number>): void;
}
});
} catch (error) {
console.error(
`callback getColor failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`callback getColor failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3367,7 +3332,7 @@ getColor(resId: number): Promise<number>
console.log("getColor promise error is " + error);
});
} catch (error) {
console.error(
`promise getColor failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`promise getColor failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3379,6 +3344,8 @@ getColor(resource: Resource, callback: AsyncCallback<number>): void;
**系统能力:** SystemCapability.Global.ResourceManager
**模型约束**:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -3412,7 +3379,7 @@ getColor(resource: Resource, callback: AsyncCallback<number>): void;
}
});
} catch (error) {
console.error(
`callback getColor failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`callback getColor failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3424,6 +3391,8 @@ getColor(resource: Resource): Promise<number>;
**系统能力**:SystemCapability.Global.ResourceManager
**模型约束**:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -3460,7 +3429,7 @@ getColor(resource: Resource): Promise<number>;
console.log("getColor promise error is " + error);
});
} catch (error) {
console.error(
`
callback getColor failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`
promise getColor failed, error code: ${error.code}, message: ${error.message}.`
);
}
```
...
...
@@ -3500,7 +3469,7 @@ getColorByName(resName: string, callback: AsyncCallback<number>): void
}
});
} catch (error) {
console.error(
`callback getColorByName failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`callback getColorByName failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3543,7 +3512,7 @@ getColorByName(resName: string): Promise<number>
console.log("getColorByName promise error is " + error);
});
} catch (error) {
console.error(
`promise getColorByName failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`promise getColorByName failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3582,7 +3551,7 @@ getColorSync(resId: number) : number;
try {
this.context.resourceManager.getColorSync($r('app.color.test').id);
} catch (error) {
console.error(
`getColorSync failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getColorSync failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3594,6 +3563,8 @@ getColorSync(resource: Resource): number
**系统能力**:SystemCapability.Global.ResourceManager
**模型约束**:此接口仅可在Stage模型下使用。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
...
...
@@ -3626,7 +3597,7 @@ getColorSync(resource: Resource): number
try {
this.context.resourceManager.getColorSync(resource);
} catch (error) {
console.error(
`getColorSync failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getColorSync failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3665,7 +3636,7 @@ getColorByNameSync(resName: string) : number;
try {
this.context.resourceManager.getColorByNameSync("test");
} catch (error) {
console.error(
`getColorByNameSync failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`getColorByNameSync failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3697,7 +3668,7 @@ addResource(path: string) : void;
try {
this.context.resourceManager.addResource(path);
} catch (error) {
console.error(
`addResource failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`addResource failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -3729,7 +3700,7 @@ removeResource(path: string) : void;
try {
this.resmgr.removeResource(path);
} catch (error) {
console.error(
`removeResource failed, error code: ${error.code}, message: ${error.message}.`
)
console.error(
`removeResource failed, error code: ${error.code}, message: ${error.message}.`
)
;
}
```
...
...
@@ -4191,3 +4162,64 @@ getRawFileDescriptor(path: string): Promise<RawFileDescriptor>
});
});
```
### closeRawFileDescriptor<sup>(deprecated)</sup>
closeRawFileDescriptor(path: string, callback: AsyncCallback<void>): void
用户关闭resources/rawfile目录下rawfile文件的descriptor,使用callback形式返回。
从API version 9开始不再维护,建议使用[closeRawFd](#closerawfd9)代替。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ----------- |
| path | string | 是 | rawfile文件路径 |
| callback | AsyncCallback<void> | 是 | 异步回调 |
**示例:**
```
ts
resourceManager.getResourceManager((error, mgr) => {
mgr.closeRawFileDescriptor("test.xml", (error, value) => {
if (error != null) {
console.log("error is " + error);
}
});
});
```
### closeRawFileDescriptor<sup>(deprecated)</sup>
closeRawFileDescriptor(path: string): Promise<void>
用户关闭resources/rawfile目录下rawfile文件的descriptor,使用Promise形式返回。
从API version 9开始不再维护,建议使用[closeRawFd](#closerawfd9-1)代替。
**系统能力**:SystemCapability.Global.ResourceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ----------- |
| path | string | 是 | rawfile文件路径 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---- |
| Promise<void> | 无返回值 |
**示例:**
```
ts
resourceManager.getResourceManager((error, mgr) => {
mgr.closeRawFileDescriptor("test.xml").then(value => {
let result = value;
}).catch(error => {
console.log("closeRawFileDescriptor promise error is " + error);
});
});
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录