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