未验证 提交 b73b7fd6 编写于 作者: O openharmony_ci 提交者: Gitee

!2840 2560 处理完成:设备使用信息统计相关文档更新

Merge pull request !2840 from ester.zhou/TR-2560
......@@ -56,14 +56,14 @@ import stats from '@ohos.bundleState';
// Use an asynchronous callback to return the result.
stats.queryBundleActiveStates(0, 20000000000000, (err, res) => {
if(err.code == 0) {
if (err) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i]));
}
} else {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
}
});
```
......@@ -77,7 +77,7 @@ import stats from '@ohos.bundleState';
stats.queryBundleStateInfos(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.');
let i = 1;
for(let key in res){
for (let key in res){
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise number : ' + i);
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key]));
i++;
......@@ -88,7 +88,9 @@ import stats from '@ohos.bundleState';
// Use an asynchronous callback to return the result.
stats.queryBundleStateInfos(0, 20000000000000, (err, res) => {
if(err.code == 0) {
if (err) {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.');
let i = 1;
for(let key in res){
......@@ -96,8 +98,6 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key]));
i++;
}
} else {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
}
});
```
......@@ -120,14 +120,14 @@ import stats from '@ohos.bundleState';
// Use an asynchronous callback to return the result.
stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => {
if(err.code == 0) {
if (err) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i]));
}
} else {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
}
}
});
```
......@@ -150,14 +150,14 @@ import stats from '@ohos.bundleState';
// Use an asynchronous callback to return the result.
stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => {
if(err.code == 0) {
if (err) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i]));
}
} else {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
}
});
```
......@@ -176,10 +176,10 @@ import stats from '@ohos.bundleState';
// Use an asynchronous callback to return the result.
stats.queryAppUsagePriorityGroup((err, res) => {
if(err.code === 0) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
} else {
if (err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
```
......@@ -198,10 +198,10 @@ import stats from '@ohos.bundleState';
// Use an asynchronous callback to return the result.
stats.isIdleState("com.ohos.camera", (err, res) => {
if(err.code === 0) {
console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
} else {
if (err) {
console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
}
});
```
......@@ -29,10 +29,10 @@ Checks whether the application specified by **bundleName** is in the idle state.
```
bundleState.isIdleState("com.ohos.camera", (err, res) => {
if(err.code === 0) {
console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
} else {
if (err) {
console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
}
});
```
......@@ -85,10 +85,10 @@ Queries the priority group of the current invoker application. This API uses an
```
bundleState.queryAppUsagePriorityGroup((err, res) => {
if(err.code === 0) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
} else {
if (err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
```
......@@ -139,7 +139,9 @@ Queries the application usage duration statistics based on the specified start t
```
bundleState.queryBundleStateInfos(0, 20000000000000, (err, res) => {
if(err.code == 0) {
if (err) {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.');
let i = 1;
for(let key in res){
......@@ -147,8 +149,6 @@ Queries the application usage duration statistics based on the specified start t
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key]));
i++;
}
} else {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
}
});
```
......@@ -215,14 +215,14 @@ Queries the application usage duration statistics in the specified time frame at
```
bundleState.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => {
if(err.code == 0) {
if (err) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i]));
}
} else {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
}
});
```
......@@ -287,14 +287,14 @@ Queries events of all applications based on the specified start time and end tim
```
bundleState.queryBundleActiveStates(0, 20000000000000, (err, res) => {
if(err.code == 0) {
if (err) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i]));
}
} else {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
}
});
```
......@@ -356,14 +356,14 @@ Queries events of this application based on the specified start time and end tim
```
bundleState.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => {
if(err.code == 0) {
if (err) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i]));
}
} else {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
}
}
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册