优化功耗效率
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 游戏主要在手机或平板电脑等电池供电的设备上玩。优化游戏的电源效率,帮助用户延长游戏时间,让他们即使设备电量未充满,也能放心地开始游戏会话。
使用最佳显示屏刷新率
显示屏刷新率是指设备显示屏面板可更改以显示新信息的速度。传统上,手持设备的刷新率为 60Hz,每秒更新显示内容 60 次。现代设备通常配备刷新率较高的显示屏,能够以 90Hz 或 120Hz 的速率更新。刷新率越高,滚动等操作的用户体验就越流畅,但显示屏面板的功耗也会增加。
游戏的目标帧速率通常为每秒 30 或 60 帧。如果显示刷新率高于游戏的目标帧速率,更高的刷新率不会带来任何好处,只会增加功耗。在高刷新率设备上,请调整显示屏刷新率,使其尽可能接近游戏的目标帧速率。
集成或启用 Swappy 帧同步库
Android Game Development Kit (AGDK) 包含一个名为 Swappy 的帧同步库。Swappy 会优化设备的显示刷新率,以尽可能与游戏帧速率相匹配。如果您使用的是自定义游戏引擎,请参阅 Frame Pacing 库指南,了解如何将该库集成到您的引擎中。
Swappy 已集成到 Unreal Engine(适用于移动设备的帧同步)和 Unity Engine(PlayerSettings.Android.optimizedFramePacing)中,并会优化显示刷新率(如果您的游戏项目中启用了此功能)。
调用 Android 帧速率 API
除了集成帧同步库之外,您还可以使用 Android 帧速率 API 直接调整显示屏刷新率。
将 Vulkan API 用于图形
Android 支持两个图形 API:旧版 OpenGL ES API 和新版 Vulkan API。Vulkan 现在是 Android 上的主要图形 API,比 OpenGL ES 更高效。如需详细了解 Vulkan 的优势和使用方法,请参阅将 Vulkan 用于图形。
响应设备热状态
设备 CPU 和 GPU 的利用率过高会产生热量。随着设备发热,功率效率会降低。如果设备过热,系统会降低 CPU 和 GPU 的速度,以降低功耗并让设备降温。这种行为称为热节流,会影响游戏的性能和电池耗电率。使用 Android Thermal API 监控设备的热状态,以调整游戏的工作负载,从而防止热节流。
查询设备游戏模式
游戏模式是一项功能,可让用户指定偏好设置,即是优先考虑性能还是电池续航时间,或者选择中性默认设置。如果您的游戏支持可变性能配置,请使用 Game Mode API 检查此偏好设置,并相应地修改游戏设置。
其他资源
Android Studio 功耗性能分析器
Unity 功耗效率演示示例 (GitHub)
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[],[],null,["# Optimize power efficiency\n\nAndroid games are played primarily on battery-powered devices such as phones or\ntablets. Optimize your game's power efficiency to help users play your game\nlonger and give them confidence to start a game session even when their device\nisn't fully charged.\n\nUse an optimal display refresh rate\n-----------------------------------\n\nDisplay refresh rate is the speed at which the display panel of a device can\nchange to show new information. Traditionally, handheld devices used a refresh\nrate of 60Hz, updating the display contents sixty times a second. Modern devices\noften feature displays with higher refresh rates capable of updating at 90Hz or\n120Hz. Higher refresh rates result in smoother user experiences for actions such\nas scrolling, but increase the power consumption of the display panel.\n\nGames commonly have a target frame rate of 30 or 60 frames per second. If the\ndisplay refresh rate is higher than the target frame rate of the game, there is\nno benefit from the higher refresh rate, only increased power consumption. On\nhigh-refresh-rate devices, adjust the display refresh rate to match your game\ntarget frame rate as closely as possible.\n\n### Integrate or enable the Swappy frame pacing library\n\nThe Android Game Development Kit (AGDK) includes a frame pacing library known as\nSwappy. Swappy optimizes the device's display refresh rate to match your game\nframe rate as closely as possible. If you are using a custom game engine, review\nthe [Frame Pacing Library](/games/sdk/frame-pacing) guide to learn how to integrate the library into\nyour engine.\n\nSwappy is already integrated into the Unreal engine ([Frame Pacing for Mobile\nDevices](https://dev.epicgames.com/documentation/en-us/unreal-engine/frame-pacing-for-mobile-devices-in-unreal-engine)) and the Unity engine\n([PlayerSettings.Android.optimizedFramePacing](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/PlayerSettings.Android-optimizedFramePacing.html))\nand optimizes the display refresh rate if enabled in your game project.\n\n### Call the Android frame rate API\n\nAs an alternative to integrating the frame pacing library, use the [Android\nframe rate API](/media/optimize/performance/frame-rate) to directly adjust the display refresh rate.\n\nUse the Vulkan API for graphics\n-------------------------------\n\nAndroid supports two graphics APIs: the older OpenGL ES API and the newer Vulkan\nAPI. Vulkan is now the primary graphics API on Android and is more efficient\nthan OpenGL ES. For more information on Vulkan's benefits and how to use it, see\n[Use Vulkan for graphics](/games/develop/vulkan/overview).\n\nRespond to device thermal conditions\n------------------------------------\n\nHigh utilization of the device's CPU and GPU generates heat. Power efficiency\ndrops as the device heats up. If a device gets too hot, it downclocks the\nspeed of the CPU and GPU to reduce power consumption and allow the device to\ncool. This behavior, referred to as thermal throttling, affects the performance\nof your game and its rate of battery drain. Use the [Android Thermal API](/games/optimize/adpf/thermal) to\nmonitor the thermal state of the device to adjust your game's workload to\nprevent thermal throttling.\n\nQuery the device Game Mode\n--------------------------\n\nGame Mode is a feature that lets the user specify a preference of whether to\ntrade off performance against battery life, battery life against performance, or\nselect a neutral default. If your game supports variable performance\nconfigurations, use the [Game Mode API](/games/optimize/adpf/gamemode/gamemode-api) to check for this preference and\nmodify your game settings accordingly.\n\nAdditional resources\n--------------------\n\n[Android Studio power profiler](/studio/profile/power-profiler)\n\n[Unity power efficiency demo sample (GitHub)](https://github.com/android/games-samples/tree/main/unity/power_efficiency_demo)"]]