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

!23778 update stationary guidelines

Merge pull request !23778 from 周澎亮/0904
......@@ -45,40 +45,43 @@
1. 订阅绝对静止的进入事件,1秒上报一次。
```js
```ts
import stationary from '@ohos.stationary';
var reportLatencyNs = 1000000000;
let reportLatencyNs = 1000000000;
try {
stationary.on('still', stationary.ActivityEvent.ENTER, reportLatencyNs, (data) => {
console.log('data='+ JSON.stringify(data));
})
} catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
} catch (error) {
let message = (error as BusinessError).message;
console.error('stationary on failed:' + message);
}
```
2. 查询绝对静止状态的进入事件。
```js
```ts
import stationary from '@ohos.stationary';
try {
stationary.once('still', (data) => {
console.log('data='+ JSON.stringify(data));
})
} catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
} catch (error) {
let message = (error as BusinessError).message;
console.error('stationary once failed:' + message);
}
```
3. 取消订阅绝对静止状态的进入事件。
```js
```ts
import stationary from '@ohos.stationary';
try {
stationary.off('still', stationary.ActivityEvent.ENTER, (data) => {
console.log('data='+ JSON.stringify(data));
})
} catch (err) {
console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
} catch (error) {
let message = (error as BusinessError).message;
console.error('stationary off failed:' + message);
}
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册