This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo 电池
提供物理设备电池信息以及相应事件监听器的库。
Android
iOS (device only)
Web
Included in Expo Go
Recommended version:
~58.0.3
expo-battery 提供物理设备的电池信息(如电池电量、设备是否正在充电等)以及相应的事件监听器。
信息 注意: 在网页上,
expo-battery依赖于 Battery Status API,该接口仅在基于 Chromium 的浏览器(Chrome、Edge、Opera)中实现。在不支持的浏览器中,getBatteryLevelAsync()会解析为-1,而getBatteryStateAsync()会解析为BatteryState.UNKNOWN。
安装
🌐 Installation
Terminal
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
🌐 Usage
Basic Battery usage
应用接口
🌐 API
import * as Battery from 'expo-battery';
No API data file found, sorry!