1# @ohos.stationary (Device Status Awareness Framework) 2 3The **stationary** module provides APIs to report the device status, including absolute still and relative still. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> This module does not support x86 emulators. 10 11## Modules to Import 12 13```ts 14import { stationary } from '@kit.MultimodalAwarenessKit'; 15``` 16 17## ActivityResponse 18 19Defines the response interface to receive the device status. 20 21**System capability**: SystemCapability.Msdp.DeviceStatus.Stationary 22 23| Name| Type| Readable| Writable| Description| 24| -------- | -------- | -------- | -------- | -------- | 25| state | [ActivityState](#activitystate) | Yes| No| New device status.| 26 27## ActivityType 28 29type ActivityType = 'still' | 'relativeStill' 30 31Enumerates the device status types. 32 33**System capability**: SystemCapability.Msdp.DeviceStatus.Stationary 34 35| Type| Description| 36| -------- | -------- | 37| 'still' | Absolutely still.| 38| 'relativeStill' | Relatively still.| 39 40## ActivityEvent 41 42Enumerates the device status events. 43 44**System capability**: SystemCapability.Msdp.DeviceStatus.Stationary 45 46| Name | Value | Description | 47| ------------------------------ | ---- | ---------------------------------------- | 48| ENTER | 1 | Event indicating entering device status. | 49| EXIT | 2 | Event indicating exiting device status.| 50| ENTER_EXIT | 3 | Event indicating entering and exiting device status.| 51 52## ActivityState 53 54Enumerates the device statuses. 55 56**System capability**: SystemCapability.Msdp.DeviceStatus.Stationary 57 58| Name | Value | Description | 59| ------------------------------ | ---- | ---------------------------------------- | 60| ENTER | 1 | Event indicating entering device status. | 61| EXIT | 2 | Event indicating exiting device status.| 62 63## stationary.on('still' | 'relativeStill') 64 65on(activity: ActivityType, event: ActivityEvent, reportLatencyNs: number, callback: Callback<ActivityResponse>): void 66 67Subscribes to the device status. 68 69**System capability**: SystemCapability.Msdp.DeviceStatus.Stationary 70 71**Parameters** 72 73| Name | Type | Mandatory| Description | 74| -------------------- | -------------------------------------------------- | ---- | ---------------------------- | 75| activity | [ActivityType](#activitytype) | Yes | Device status type. | 76| event | [ActivityEvent](#activityevent) | Yes | Event type. | 77| reportLatencyNs | number | Yes | Event reporting period. | 78| callback | Callback<[ActivityResponse](#activityresponse)\> | Yes | Callback used to receive reported data. | 79 80**Example** 81 82```ts 83let reportLatencyNs = 100; 84stationary.on('still', stationary.ActivityEvent.ENTER, reportLatencyNs, (data) => { 85 console.log('data='+ JSON.stringify(data)); 86}) 87``` 88 89## stationary.once('still' | 'relativeStill') 90 91once(activity: ActivityType, callback: Callback<ActivityResponse>): void 92 93Obtains the device status. 94 95**System capability**: SystemCapability.Msdp.DeviceStatus.Stationary 96 97**Parameters** 98 99| Name | Type | Mandatory| Description | 100| -------------------- | -------------------------------------------------- | ---- | ---------------------------- | 101| activity | [ActivityType](#activitytype) | Yes | Device status type. | 102| callback | Callback<[ActivityResponse](#activityresponse)\> | Yes | Callback used to receive reported data. | 103 104**Example** 105 106```ts 107stationary.once('still', (data) => { 108 console.log("data="+ JSON.stringify(data)); 109}) 110``` 111 112## stationary.off('still' | 'relativeStill') 113 114off(activity: ActivityType, event: ActivityEvent, callback?: Callback<ActivityResponse>): void 115 116Unsubscribes from the device status. 117 118**System capability**: SystemCapability.Msdp.DeviceStatus.Stationary 119 120**Parameters** 121 122| Name | Type | Mandatory| Description | 123| -------------------- | -------------------------------------------------- | ---- | ---------------------------- | 124| activity | [ActivityType](#activitytype) | Yes | Device status type. | 125| event | [ActivityEvent](#activityevent) | Yes | Event type. | 126| callback | Callback: \<[ActivityResponse](#activityresponse)> | No | Callback used to receive reported data. If no value or **undefined** is passed, all callbacks associated with the specified event in the process will be unregistered. | 127 128**Example** 129 130```ts 131stationary.off('still', stationary.ActivityEvent.ENTER); 132``` 133