省电功能简介
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如今,用户几乎所有事情都依赖于移动设备,从发送电子邮件和管理财务,到流式传输视频和流式传输及玩视频游戏。为了发挥作用,大多数应用都需要来自远程服务的数据、图片和其他媒体内容。请务必记住,您的应用只是用户设备上的众多应用之一,所有应用都在争夺网络资源。如果管理不当,这会对电池性能产生显著的负面影响,并会不必要地使用用户有限的网络带宽。
自 Android 8.0 起,操作系统引入了多项更新,有助于延长电池续航时间、改善用户体验和维护系统健康状况。不过,作为开发者,您还可以自行采用其他注意事项、策略和模式。您的应用向网络发出的请求是主要的耗电来源,因为这些请求依赖于高功耗的移动网络和 WLAN 无线装置。
在本指南中,您将了解以下内容:
- 应用的连接模式如何与无线装置状态机进行交互。
- 如何采用相关技巧来最大限度地减少数据连接的影响。
- 如何排查连接速度缓慢的问题。
- 如何仅在特定条件下(例如设备正在充电或连接到 Wi-Fi 网络时)运行后台工作。
- 如何跟踪应用在一段时间内的电池用量。
最后,您将了解三大类更新:用户发起的更新、应用发起的更新和服务器发起的更新,以及可用于最大限度提高每类更新效率的工具和技术。
归根结底,作为开发者社区的一员,我们都有责任为用户提供最佳应用体验。
其他资料
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# About preserving battery\n\nUsers rely on their mobile devices for virtually everything these days, from\nsending emails and managing finances, to streaming videos and streaming and\nplaying video games. In order to be useful, most apps require data, images, and\nother media from remote services. It's important to remember that your app is\njust one of many apps on the user's device, all competing for network resources.\nManaged poorly, this can have a dramatic and detrimental impact on battery\nperformance and unnecessarily use the user's limited network bandwidth.\n\nStarting with [Android 8.0](/about/versions/oreo/android-8.0-changes), several\nupdates were introduced to the OS which help preserve battery, user experience,\nand system health. However, there are additional considerations, strategies, and\npatterns that you as a developer can employ yourself, as well. Requests that\nyour app makes to the network can be a major cause of battery drain because\nthey rely on the heavily power-consuming cellular and Wi-Fi radios.\n\nIn this guide, you'll learn about the following:\n\n- How your app's connectivity model interacts with the wireless radio state machine.\n- How to employ techniques for minimizing the impact of your data connection.\n- How to troubleshoot slow connections.\n- How to run background work only under specific conditions such as when the device is charging or on Wi-Fi.\n- How to track your app's battery usage over time.\n\nFinally, you'll learn about three broad categories of updates:\n[User-initiated](/develop/connectivity/minimize-effect-regular-updates#user-initiated),\n[App-initiated](/develop/connectivity/minimize-effect-regular-updates#app-initiated),\nand\n[Server-initiated](/develop/connectivity/minimize-effect-regular-updates#server-initiated),\nwith tools and techniques for maximizing the efficiency of each category.\n\nUltimately, it's all of our responsibilities as a developer community to provide\nthe best app experience for our users.\n\nAdditional material\n-------------------"]]