> For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt.

# startDeviceMotionListening

开始监听设备方向变化。

## 扫码预览

![扫码预览 startDeviceMotionListening](https://api.qrserver.com/v1/create-qr-code/?size=200x200\&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fdevice-motion%252Findex)

## 支持版本

前端库版本不低于 `0.0.25`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>支持</td></tr>
<tr><td>iOS</td><td>支持</td></tr>
<tr><td>PC</td><td>不支持</td></tr>
<tr><td>HarmonyOS</td><td>不支持</td></tr>
</tbody>
</table>

## 支持场景

<table>
<thead>
<tr><th>场景</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>页面</td><td>支持</td></tr>
<tr><td>卡片</td><td>不支持</td></tr>
</tbody>
</table>

## 接入准备

### 前置条件

- 无额外前置条件；建议在启动前注册 `onDeviceMotionChange`

## 使用说明

需配对调用 stopDeviceMotionListening。

- 不再需要时及时调用 `stopDeviceMotionListening`，避免持续采集造成额外功耗

## 调用方式

### 异步 API

```typescript
startDeviceMotionListening(params?: StartDeviceMotionListeningParams): Promise<object>
```

## 入参

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>interval</code></td><td><code>SensorInterval</code></td><td>否</td><td><code>normal</code></td><td>game 表示约 20 次/秒，ui 表示约 60 次/秒，normal 表示约 5 次/秒</td><td>监听频率。</td></tr>
</tbody>
</table>

## 调用示例

```typescript
import { startDeviceMotionListening } from '@doubao-dev/framework/api';

await startDeviceMotionListening({ interval: 'normal' });
```

## 成功返回

无返回字段。

### 返回示例

```json
{}
```

## 错误处理

错误对象和通用错误码见 [通用错误处理](/apps-plugin/docs/js-api/common-errors.md#错误返回)。

### 失败示例

```json
{
  "errNo": 103,
  "errMsg": "feature not support"
}
```

### 错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>平台</th><th>触发条件</th><th>处理建议</th></tr>
</thead>
<tbody>
<tr><td><code>103</code></td><td><code>feature not support</code></td><td>Android、iOS</td><td>当前设备不支持方向传感器或无法注册监听</td><td>在具备方向传感器的设备上调用，或提前提示用户设备不支持。</td></tr>
</tbody>
</table>

#### 通用错误码

<table>
<thead>
<tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
</thead>
<tbody>
<tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
</tbody>
</table>
