> 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.

# setKeepScreenOn

设置屏幕常亮状态。

## 扫码预览

![扫码预览 setKeepScreenOn](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%252Fset-keep-screen-on%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>

## 使用说明

- 不再需要常亮时应主动将 keepScreenOn 设为 false，避免额外功耗

## 调用方式

### 异步 API

```typescript
setKeepScreenOn(params: SetKeepScreenOnParams): Promise<object>
```

## 入参

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>keepScreenOn</code></td><td><code>boolean</code></td><td>是</td><td>-</td><td>-</td><td>是否保持屏幕常亮。</td></tr>
</tbody>
</table>

## 调用示例

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

await setKeepScreenOn({ keepScreenOn: true });
```

## 成功返回

无返回字段。

### 返回示例

```json
{}
```

## 错误处理

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

### 错误码

#### 通用错误码

<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</td></tr>
</tbody>
</table>

## 平台差异

- **iOS**：页面销毁后常亮状态会自动恢复
- **iOS**：设置常亮恒返回成功，无失败错误码
