openharmony 鸿蒙 js-apis-awareness-deviceStatus-sys

2026-08-25 浏览 (1)

@ohos.multimodalAwareness.deviceStatus (Device Status Awareness) (System API)

The deviceStatus module provides the device status awareness functionality.

NOTE

The initial APIs of this module are supported since API version 20. Newly added APIs will be marked with a superscript to indicate their earliest API version. The APIs provided by this module are system APIs.

Modules to Import

import { deviceStatus } from '@kit.MultimodalAwarenessKit';

deviceStatus.getDeviceRotationRadian()

getDeviceRotationRadian(): Promise<DeviceRotationRadian>

Obtains the device posture data.

The posture data contains the rotation angles of the x, y, and z axes, that is, the Euler angles of the three axes. The definitions of the three axes are the same as those of the device sensor, and the right-handed coordinate system is used. Posture rotation angles are calculated under the z-x-y intrinsic rotation order, and derived by converting quaternions obtained via sensor fusion.

System capability: SystemCapability.MultimodalAwareness.DeviceStatus

System API: This is a system API.

Error codes

For details about the error codes, see Device Status Awareness Error Codes and Universal Error Codes.

IDError Message
202Permission check failed. A non-system application uses the system API.
801Capability not supported. Function can not work correctly due to limited device capabilities.
32500001Service exception.

Example

import { deviceStatus } from '@kit.MultimodalAwarenessKit';
import { BusinessError } from '@kit.BasicServicesKit';

try {
   deviceStatus.getDeviceRotationRadian().then((radian: deviceStatus.DeviceRotationRadian) => {
      console.info('x:' + radian.x + ' y:' + radian.y + ' z:' + radian.z);
   }).catch((err: BusinessError) => {
      console.error('get device rotation radian failed, errmsg:' + err);
   })
} catch (err) {
   console.error('invoke failed, errmsg:' + err)
}

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 errorcode-onScreen

openharmony 鸿蒙 js-apis-awareness-metadataBinding-sys

openharmony 鸿蒙 errorcode-metadataBinding

openharmony 鸿蒙 js-apis-awareness-motion

openharmony 鸿蒙 js-apis-awareness-metadataBinding

openharmony 鸿蒙 Readme-EN

openharmony 鸿蒙 errorcode-userStatus

openharmony 鸿蒙 errorcode-deviceStatus

openharmony 鸿蒙 js-apis-awareness-onScreen-sys

openharmony 鸿蒙 js-apis-stationary

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/zGvumurJ