Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
e257071f
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看板
提交
e257071f
编写于
4月 12, 2022
作者:
H
houdisheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改评审意见
Signed-off-by:
N
houdisheng
<
houdisheng@huawei.com
>
上级
eda5de45
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
25 addition
and
25 deletion
+25
-25
zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
...ice-usage-statistics/device-usage-statistics-dev-guide.md
+11
-11
zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
...ation-dev/reference/apis/js-apis-deviceUsageStatistics.md
+14
-14
未找到文件。
zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
浏览文件 @
e257071f
...
...
@@ -21,7 +21,7 @@ import stats from '@ohos.bundleState';
| function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback
<
Array
<
BundleStateInfo
>>
): void | 通过指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。 |
| function queryAppUsagePriorityGroup(callback: AsyncCallback
<
number
>
): void | 查询(返回)当前调用者应用的使用优先级群组。 |
| function isIdleState(bundleName: string, callback: AsyncCallback
<
boolean
>
): void | 判断指定Bundle Name的应用当前是否是空闲状态。 |
| function get
ModuleUsageRecord
(maxNum: number, callback: AsyncCallback
<
BundleActiveModuleInfo
>
): void | 根据maxNum,查询FA使用记录,返回不超过maxNum条FA使用记录。 |
| function get
RecentUsageModules
(maxNum: number, callback: AsyncCallback
<
BundleActiveModuleInfo
>
): void | 根据maxNum,查询FA使用记录,返回不超过maxNum条FA使用记录。 |
## 开发步骤
...
...
@@ -213,25 +213,25 @@ import stats from '@ohos.bundleState';
import stats from '@ohos.bundleState'
// 异步方法promise方式
stats.get
ModuleUsageRecord
(this.maxNum).then( res => {
console.log('BUNDLE_ACTIVE get
ModuleUsageRecord
promise succeeded');
stats.get
RecentUsageModules
(this.maxNum).then( res => {
console.log('BUNDLE_ACTIVE get
RecentUsageModules
promise succeeded');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE get
ModuleUsageRecord
promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE get
ModuleUsageRecord
promise result ' + JSON.stringify(res[i]));
console.log('BUNDLE_ACTIVE get
RecentUsageModules
promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE get
RecentUsageModules
promise result ' + JSON.stringify(res[i]));
}
}).catch( err=> {
console.log('BUNDLE_ACTIVE get
ModuleUsageRecord
promise failed, because: ' + err.code);
console.log('BUNDLE_ACTIVE get
RecentUsageModules
promise failed, because: ' + err.code);
});
// 异步方法callback方式
stats.get
ModuleUsageRecord
(this.maxNum,(err, res) => {
stats.get
RecentUsageModules
(this.maxNum,(err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE get
ModuleUsageRecord
callback failed, because: ' + err.code);
console.log('BUNDLE_ACTIVE get
RecentUsageModules
callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE get
ModuleUsageRecord
callback succeeded.');
console.log('BUNDLE_ACTIVE get
RecentUsageModules
callback succeeded.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE get
ModuleUsageRecord
callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE get
ModuleUsageRecord
callback result ' + JSON.stringify(res[i]));
console.log('BUNDLE_ACTIVE get
RecentUsageModules
callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE get
RecentUsageModules
callback result ' + JSON.stringify(res[i]));
}
}
});
...
...
zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
浏览文件 @
e257071f
...
...
@@ -403,9 +403,9 @@ queryCurrentBundleActiveStates(begin: number, end: number): Promise<Array<
});
```
## bundleState.get
ModuleUsageRecord
<sup>9+</sup>
## bundleState.get
RecentUsageModules
<sup>9+</sup>
get
ModuleUsageRecord
(maxNum: number): Promise
<
Array
<
BundleActiveModuleInfo
>>
get
RecentUsageModules
(maxNum: number): Promise
<
Array
<
BundleActiveModuleInfo
>>
据maxNum,查询FA使用记录,使用Promise形式返回不超过maxNum条FA使用记录,maxNum最大为1000。
...
...
@@ -428,20 +428,20 @@ getModuleUsageRecord(maxNum: number): Promise<Array<BundleActiveModuleInfo
**示例**
:
```
js
bundleState
.
get
ModuleUsageRecord
(
this
.
maxNum
).
then
(
res
=>
{
console
.
log
(
'
BUNDLE_ACTIVE get
ModuleUsageRecord
promise succeeded
'
);
bundleState
.
get
RecentUsageModules
(
this
.
maxNum
).
then
(
res
=>
{
console
.
log
(
'
BUNDLE_ACTIVE get
RecentUsageModules
promise succeeded
'
);
for
(
let
i
=
0
;
i
<
res
.
length
;
i
++
)
{
console
.
log
(
'
BUNDLE_ACTIVE get
ModuleUsageRecord
promise number :
'
+
(
i
+
1
));
console
.
log
(
'
BUNDLE_ACTIVE get
ModuleUsageRecord
promise result
'
+
JSON
.
stringify
(
res
[
i
]));
console
.
log
(
'
BUNDLE_ACTIVE get
RecentUsageModules
promise number :
'
+
(
i
+
1
));
console
.
log
(
'
BUNDLE_ACTIVE get
RecentUsageModules
promise result
'
+
JSON
.
stringify
(
res
[
i
]));
}
}).
catch
(
err
=>
{
console
.
log
(
'
BUNDLE_ACTIVE get
ModuleUsageRecord
promise failed, because:
'
+
err
.
code
);
console
.
log
(
'
BUNDLE_ACTIVE get
RecentUsageModules
promise failed, because:
'
+
err
.
code
);
});
```
## bundleState.get
ModuleUsageRecord
<sup>9+</sup>
## bundleState.get
RecentUsageModules
<sup>9+</sup>
get
ModuleUsageRecord
(maxNum: number): Promise
<
Array
<
BundleActiveModuleInfo
>>
get
RecentUsageModules
(maxNum: number): Promise
<
Array
<
BundleActiveModuleInfo
>>
查询FA使用记录。使用callback形式返回数量最大不超过maxNum设置的值,maxNum最大为1000。
...
...
@@ -459,14 +459,14 @@ getModuleUsageRecord(maxNum: number): Promise<Array<BundleActiveModuleInfo
**示例**
:
```
js
bundleState
.
get
ModuleUsageRecord
(
this
.
maxNum
,(
err
,
res
)
=>
{
bundleState
.
get
RecentUsageModules
(
this
.
maxNum
,(
err
,
res
)
=>
{
if
(
err
)
{
console
.
log
(
'
BUNDLE_ACTIVE get
ModuleUsageRecord
callback failed, because:
'
+
err
.
code
);
console
.
log
(
'
BUNDLE_ACTIVE get
RecentUsageModules
callback failed, because:
'
+
err
.
code
);
}
else
{
console
.
log
(
'
BUNDLE_ACTIVE get
ModuleUsageRecord
callback succeeded.
'
);
console
.
log
(
'
BUNDLE_ACTIVE get
RecentUsageModules
callback succeeded.
'
);
for
(
let
i
=
0
;
i
<
res
.
length
;
i
++
)
{
console
.
log
(
'
BUNDLE_ACTIVE get
ModuleUsageRecord
callback number :
'
+
(
i
+
1
));
console
.
log
(
'
BUNDLE_ACTIVE get
ModuleUsageRecord
callback result
'
+
JSON
.
stringify
(
res
[
i
]));
console
.
log
(
'
BUNDLE_ACTIVE get
RecentUsageModules
callback number :
'
+
(
i
+
1
));
console
.
log
(
'
BUNDLE_ACTIVE get
RecentUsageModules
callback result
'
+
JSON
.
stringify
(
res
[
i
]));
}
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录