my.startDeviceMotionListening

Start listening for changes in the device's orientation.

Parameters

Property

Type

Default

Required

Description

interval

String

normal

No

The execution frequency of the callback function that listens for device orientation change events.

Valid values:

game: The callback frequency suitable for updating games, approximately once every 20 ms.

ui: The callback frequency suitable for updating the UI, approximately once every 60 ms.

normal: The standard callback frequency, approximately once every 200 ms.

success

Function

-

No

Callback function upon call success.

fail

Function

-

No

Callback function upon call failure.

complete

Function

-

No

Callback function upon call completion, regardless of success or failure.

Error codes

Error code

Error message

Further action

1001

The system doesn't support the relevant capabilities.

Try again with a different device.

Sample code

copy
my.startDeviceMotionListening({
  interval: 'normal',
  success: function (res) {
    console.log(res);
  },
  fail: function (err) {
    console.log(err);
  }
});