Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Coping0606
Docs
提交
12076039
D
Docs
项目概览
Coping0606
/
Docs
与 Fork 源项目一致
Fork自
OpenHarmony / Docs
通知
1
Star
1
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
12076039
编写于
4月 13, 2022
作者:
H
houdisheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
同步api名称修改
Signed-off-by:
N
houdisheng
<
houdisheng@huawei.com
>
上级
cfa4ab49
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
27 deletion
+27
-27
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
+16
-16
未找到文件。
zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
浏览文件 @
12076039
...
...
@@ -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 getRecent
Usage
Modules(maxNum: number, callback: AsyncCallback
<
BundleActiveModuleInfo
>
): void | 根据maxNum,查询FA使用记录,返回不超过maxNum条FA使用记录。 |
| function getRecent
lyUsed
Modules(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.getRecent
Usage
Modules(this.maxNum).then( res => {
console.log('BUNDLE_ACTIVE getRecent
Usage
Modules promise succeeded');
stats.getRecent
lyUsed
Modules(this.maxNum).then( res => {
console.log('BUNDLE_ACTIVE getRecent
lyUsed
Modules promise succeeded');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecent
Usage
Modules promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecent
Usage
Modules promise result ' + JSON.stringify(res[i]));
console.log('BUNDLE_ACTIVE getRecent
lyUsed
Modules promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecent
lyUsed
Modules promise result ' + JSON.stringify(res[i]));
}
}).catch( err=> {
console.log('BUNDLE_ACTIVE getRecent
Usage
Modules promise failed, because: ' + err.code);
console.log('BUNDLE_ACTIVE getRecent
lyUsed
Modules promise failed, because: ' + err.code);
});
// 异步方法callback方式
stats.getRecent
Usage
Modules(this.maxNum,(err, res) => {
stats.getRecent
lyUsed
Modules(this.maxNum,(err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecent
Usage
Modules callback failed, because: ' + err.code);
console.log('BUNDLE_ACTIVE getRecent
lyUsed
Modules callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE getRecent
Usage
Modules callback succeeded.');
console.log('BUNDLE_ACTIVE getRecent
lyUsed
Modules callback succeeded.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecent
Usage
Modules callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecent
Usage
Modules callback result ' + JSON.stringify(res[i]));
console.log('BUNDLE_ACTIVE getRecent
lyUsed
Modules callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecent
lyUsed
Modules callback result ' + JSON.stringify(res[i]));
}
}
});
...
...
zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
浏览文件 @
12076039
...
...
@@ -403,11 +403,11 @@ queryCurrentBundleActiveStates(begin: number, end: number): Promise<Array<
});
```
## bundleState.getRecent
Usage
Modules<sup>9+</sup>
## bundleState.getRecent
lyUsed
Modules<sup>9+</sup>
getRecent
Usage
Modules(maxNum: number): Promise
<
Array
<
BundleActiveModuleInfo
>>
getRecent
lyUsed
Modules(maxNum: number): Promise
<
Array
<
BundleActiveModuleInfo
>>
据maxNum,查询FA使用记录,使用Promise形式返回不超过maxNum条FA使用记录,maxNum最大为1000。
据maxNum,查询FA使用记录,使用Promise形式返回不超过maxNum条FA使用记录,
FA使用记录由近及远排序,
maxNum最大为1000。
**需要权限**
:ohos.permission.BUNDLE_ACTIVE_INFO
...
...
@@ -428,22 +428,22 @@ getRecentUsageModules(maxNum: number): Promise<Array<BundleActiveModuleInf
**示例**
:
```
js
bundleState
.
getRecent
Usage
Modules
(
this
.
maxNum
).
then
(
res
=>
{
console
.
log
(
'
BUNDLE_ACTIVE getRecent
Usage
Modules promise succeeded
'
);
bundleState
.
getRecent
lyUsed
Modules
(
this
.
maxNum
).
then
(
res
=>
{
console
.
log
(
'
BUNDLE_ACTIVE getRecent
lyUsed
Modules promise succeeded
'
);
for
(
let
i
=
0
;
i
<
res
.
length
;
i
++
)
{
console
.
log
(
'
BUNDLE_ACTIVE getRecent
Usage
Modules promise number :
'
+
(
i
+
1
));
console
.
log
(
'
BUNDLE_ACTIVE getRecent
Usage
Modules promise result
'
+
JSON
.
stringify
(
res
[
i
]));
console
.
log
(
'
BUNDLE_ACTIVE getRecent
lyUsed
Modules promise number :
'
+
(
i
+
1
));
console
.
log
(
'
BUNDLE_ACTIVE getRecent
lyUsed
Modules promise result
'
+
JSON
.
stringify
(
res
[
i
]));
}
}).
catch
(
err
=>
{
console
.
log
(
'
BUNDLE_ACTIVE getRecent
Usage
Modules promise failed, because:
'
+
err
.
code
);
console
.
log
(
'
BUNDLE_ACTIVE getRecent
lyUsed
Modules promise failed, because:
'
+
err
.
code
);
});
```
## bundleState.getRecent
Usage
Modules<sup>9+</sup>
## bundleState.getRecent
lyUsed
Modules<sup>9+</sup>
getRecent
Usage
Modules(maxNum: number, callback: AsyncCallback
<
Array
<
BundleActiveModuleInfo
>>
): void
getRecent
lyUsed
Modules(maxNum: number, callback: AsyncCallback
<
Array
<
BundleActiveModuleInfo
>>
): void
查询FA使用记录。使用
callback形式返回数量最大不超过maxNum设置的值
,maxNum最大为1000。
查询FA使用记录。使用
CallBack形式返回数量最大不超过maxNum设置的值,FA使用记录由近及远排序
,maxNum最大为1000。
**需要权限**
:ohos.permission.BUNDLE_ACTIVE_INFO
...
...
@@ -459,14 +459,14 @@ getRecentUsageModules(maxNum: number, callback: AsyncCallback<Array<Bundle
**示例**
:
```
js
bundleState
.
getRecent
Usage
Modules
(
this
.
maxNum
,(
err
,
res
)
=>
{
bundleState
.
getRecent
lyUsed
Modules
(
this
.
maxNum
,(
err
,
res
)
=>
{
if
(
err
)
{
console
.
log
(
'
BUNDLE_ACTIVE getRecent
Usage
Modules callback failed, because:
'
+
err
.
code
);
console
.
log
(
'
BUNDLE_ACTIVE getRecent
lyUsed
Modules callback failed, because:
'
+
err
.
code
);
}
else
{
console
.
log
(
'
BUNDLE_ACTIVE getRecent
Usage
Modules callback succeeded.
'
);
console
.
log
(
'
BUNDLE_ACTIVE getRecent
lyUsed
Modules callback succeeded.
'
);
for
(
let
i
=
0
;
i
<
res
.
length
;
i
++
)
{
console
.
log
(
'
BUNDLE_ACTIVE getRecent
Usage
Modules callback number :
'
+
(
i
+
1
));
console
.
log
(
'
BUNDLE_ACTIVE getRecent
Usage
Modules callback result
'
+
JSON
.
stringify
(
res
[
i
]));
console
.
log
(
'
BUNDLE_ACTIVE getRecent
lyUsed
Modules callback number :
'
+
(
i
+
1
));
console
.
log
(
'
BUNDLE_ACTIVE getRecent
lyUsed
Modules callback result
'
+
JSON
.
stringify
(
res
[
i
]));
}
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录