提交 b12bfe97 编写于 作者: Z zzzzl-top

update stationary guidelines Signed-off-by:zzzzl-top<zhoupengliang1@huawei.com>

Signed-off-by: Nzzzzl-top <zhoupengliang1@huawei.com>
上级 a4498fa1
......@@ -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.
先完成此消息的编辑!
想要评论请 注册