自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
電源管理
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
電池續航力向來是使用者關注的焦點。為了延長電池續航力,Android 會持續新增新功能,協助平台最佳化應用程式和裝置的離線行為。
Android 包含以下電池續航力強化功能:
-
應用程式限制。
平台可以建議會對電池續航力造成負面影響的應用程式,讓使用者選擇限制這些應用程式耗用資源。根據預設,系統不會限制應用程式的背景運作。
- 應用程式待命。平台可將未使用的應用程式置於應用程式待命模式,暫時限制網路存取權,並延後這些應用程式的同步處理和工作。
-
Doze。如果使用者長時間未積極使用裝置 (螢幕關閉且處於靜止狀態),平台就會進入深度睡眠狀態 (定期恢復正常運作)。在 Android 7.0 以上版本中,當使用者關閉裝置螢幕但仍在移動時,Doze 也會觸發較輕量的最佳化設定。
- 限制 USB 備份和還原期間的電力傳輸。執行 USB 備份或還原作業時,請將
UsbPort
類別的 enableLimitPowerTransfer
方法設為 true
,以停用充電功能並限制電源來源。如要確認功率受限,請呼叫 UsbPortStatus
類別的 isPowerTransferLimited
方法。當 isPowerTransferLimited
為 true
時,Android 裝置會將電力消耗量降至 0 (或硬體允許的最低值),並將電源電流限制為 0。只有在兩個連接埠合作夥伴都支援 USB 電源供應 (PD) 規格時,才能強制限制來源電源。如要將電力使用量恢復為預設狀態,請將 enableLimitPowerTransfer
設為 false
。當 USB 傳輸線拔除時,系統也會傳回預設狀態。
-
豁免情形。預先載入的系統應用程式和雲端訊息服務通常會根據預設豁免應用程式待命和 Doze 功能。應用程式開發人員可以使用意圖,將這些設定套用至應用程式。使用者可以在「設定」選單中,將應用程式排除在「應用程式待命」和「Doze」省電模式之外。
-
智慧手環。應用程式背景行為追蹤器會監控應用程式的前景和背景耗電量,判斷應用程式是否違反某些政策。
排除的應用程式
您可以將應用程式排除在打盹或應用程式待命的範圍之外。下列用途可能需要豁免:
警告:請勿豁免應用程式,以免無法進行測試和最佳化。不必要的例外狀況會破壞 Doze 和應用程式待命功能的好處,並可能影響使用者體驗,因此我們強烈建議您盡量減少這類例外狀況,因為這類例外狀況會讓應用程式破壞平台對電池用量的良好控管機制。如果使用者對這些應用程式的耗電量感到不滿,可能會導致他們感到挫折、體驗不佳 (並對應用程式留下負面評論),以及向客戶服務團隊提出問題。基於這些原因,我們強烈建議您不要豁免第三方應用程式,而是只豁免雲端訊息服務或具有類似功能的應用程式。
預設豁免的應用程式會列在「設定」>「應用程式和通知」>「特殊應用程式存取權」>「電池效能最佳化」中。這份清單用於讓應用程式免於進入 Doze 和 App Standby 模式。為向使用者提供透明度,設定選單「必須」顯示所有豁免的應用程式。
使用者可以依序前往「設定」>「應用程式與通知」>「APP-NAME」>「電池」>「電池最佳化」,然後選取要關閉 (或重新開啟) 最佳化的應用程式。不過,使用者無法變更系統映像檔中預設豁免的任何應用程式或服務的例外狀態。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Power management\n\nBattery life is a perennial user concern. To extend battery life, Android\ncontinually adds new features to help the platform optimize the off-charger\nbehavior of apps and devices.\n\nAndroid includes the following battery life enhancements:\n\n- [App restrictions](/docs/core/power/app_mgmt#app-restrictions). The platform can suggest apps that negatively affect battery life, so that users can choose to restrict those apps from consuming resources. Apps aren't background restricted by default.\n- [App standby](/docs/core/power/app_mgmt#app-standby). The platform can place unused apps in App standby mode, temporarily restricting network access and deferring syncs and jobs for those apps.\n- [Doze](/docs/core/power/platform_mgmt#doze). The platform can enter a state of deep sleep (periodically resuming normal operations) if users haven't actively used their device (screen off and stationary) for extended periods of time. Android 7.0 and higher also enables Doze to trigger a lighter set of optimizations when users turn off the device screen yet continue to move around.\n- Limiting power transfer during USB backup and restore. When performing a USB backup or restore, set the `UsbPort` class's `enableLimitPowerTransfer` method to `true` to disable charging and limit the sourcing power. To verify that power is limited, call `UsbPortStatus` class's `isPowerTransferLimited` method. When `isPowerTransferLimited` is `true`, the Android device reduces the power draw as a sink to 0 (or the lowest possible value allowed by hardware) and limits the source current to 0. Limiting source power can be enforced only when both port partners support USB power delivery (PD) specification. To return power usage to the defatult state, set `enableLimitPowerTransfer` to `false`. The default state is also returned when the USB cable is disconnected.\n- [Exemptions](#exempt-apps). Preloaded system apps and cloud messaging services are typically exempted from App standby and Doze by default. App developers can use intents to apply these settings to their apps. Users can exempt apps from App standby and Doze power-saving modes in the Settings menu.\n- [Trackers](/docs/core/power/trackers). App background behavior trackers monitor apps' foreground and background battery usage to determine if the apps violate some policy.\n\nExempt apps\n-----------\n\nYou can exempt apps from being subject to Doze or App standby.\nExemptions may be needed in the following use cases:\n\n- Device manufacturers using a cloud messaging platform other than [Firebase\n cloud messaging (FCM)](https://firebase.google.com/docs/cloud-messaging/)\n- Carrier using non-FCM cloud messaging platform\n- Third-party app using non-FCM cloud messaging platform\n\n**Warning:** Don't exempt apps to avoid testing\nand optimizing. Unnecessary exemptions undermine the benefits of Doze and App\nstandby and can compromise the user experience, so we strongly suggest\nminimizing such exemptions as they allow apps to defeat beneficial\ncontrols the platform has over power use. If users become unhappy about the\npower consumption of these apps, it can lead to frustration, bad experiences\n(and negative reviews for the app), and customer support questions. For these\nreasons, we strongly recommend that you don't exempt third-party apps\nand instead exempt only cloud messaging services or apps with similar\nfunctions.\n\nApps exempted by default are listed in **Settings \\\u003e App \\&\nNotifications \\\u003e Special app access \\\u003e Battery Optimization** . This list is\nused for exempting the app from both Doze and App standby modes. To provide\ntransparency to the user, the Settings menu **MUST** show all\nexempted apps.\n\nUsers can manually exempt apps using **Settings \\\u003e App \\& Notifications \\\u003e\n\u003cvar translate=\"no\"\u003eAPP-NAME\u003c/var\u003e \\\u003e Battery \\\u003e Battery Optimization** and then selecting the\napp to turn off (or back on) optimization. However, users can't change the except status of any\napp or service that is exempted by default in the system image."]]