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

!7744 【轻量级 PR】:【OpenHarmony开源贡献者计划2022】update...

!7744 【轻量级 PR】:【OpenHarmony开源贡献者计划2022】update zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md.
Merge pull request !7744 from Turbo1125hh/N/A
...@@ -341,14 +341,14 @@ import stats from '@ohos.bundleState'; ...@@ -341,14 +341,14 @@ import stats from '@ohos.bundleState';
} }
}); });
//有参异步promise方式 // 有参异步promise方式
stats.queryAppUsagePriorityGroup(this.bundleName).then(res => { stats.queryAppUsagePriorityGroup(this.bundleName).then(res => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res)); console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch(err => { }).catch(err => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code); console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
}); });
//有参异步方法callback方式 // 有参异步方法callback方式
stats.queryAppUsagePriorityGroup(this.bundleName, (err, res) => { stats.queryAppUsagePriorityGroup(this.bundleName, (err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code); console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
...@@ -363,13 +363,13 @@ import stats from '@ohos.bundleState'; ...@@ -363,13 +363,13 @@ import stats from '@ohos.bundleState';
```javascript ```javascript
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
//异步方法promise // 异步方法promise
stats.setBundleGroup(this.bundleName, this.newGroup).then(() => { stats.setBundleGroup(this.bundleName, this.newGroup).then(() => {
console.log('BUNDLE_ACTIVE SetBundleGroup promise succeeded.'); console.log('BUNDLE_ACTIVE SetBundleGroup promise succeeded.');
}).catch( err => { }).catch( err => {
console.log('BUNDLE_ACTIVE SetBundleGroup promise failed. because: ' + err.code); console.log('BUNDLE_ACTIVE SetBundleGroup promise failed. because: ' + err.code);
}); });
//异步方法callback // 异步方法callback
stats.setBundleGroup(this.bundleName, this.newGroup, (err) => { stats.setBundleGroup(this.bundleName, this.newGroup, (err) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE SetBundleGroup callback failed. because: ' + err.code); console.log('BUNDLE_ACTIVE SetBundleGroup callback failed. because: ' + err.code);
...@@ -384,7 +384,7 @@ import stats from '@ohos.bundleState'; ...@@ -384,7 +384,7 @@ import stats from '@ohos.bundleState';
```javascript ```javascript
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
//异步方法promise形式 // 异步方法promise形式
let onBundleGroupChanged = (err,res) => { let onBundleGroupChanged = (err,res) => {
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.'); console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result oldGroup is : ' + res.oldGroup); console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result oldGroup is : ' + res.oldGroup);
...@@ -398,7 +398,7 @@ import stats from '@ohos.bundleState'; ...@@ -398,7 +398,7 @@ import stats from '@ohos.bundleState';
}).catch(err => { }).catch(err => {
console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise failed. because: ' + err.code); console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise failed. because: ' + err.code);
}); });
//异步方法callback形式 // 异步方法callback形式
let onBundleGroupChanged = (err,res) => { let onBundleGroupChanged = (err,res) => {
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.'); console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result‘s oldGroup is : ' + res.oldGroup); console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result‘s oldGroup is : ' + res.oldGroup);
...@@ -421,13 +421,13 @@ import stats from '@ohos.bundleState'; ...@@ -421,13 +421,13 @@ import stats from '@ohos.bundleState';
```javascript ```javascript
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
//promise // promise
stats.unRegisterGroupCallBack().then(() => { stats.unRegisterGroupCallBack().then(() => {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise succeeded.'); console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise succeeded.');
}).catch(err => { }).catch(err => {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise failed. because: ' + err.code); console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise failed. because: ' + err.code);
}); });
//callback // callback
stats.unRegisterGroupCallBack((err) => { stats.unRegisterGroupCallBack((err) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback failed, because: ' + err.code);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册