搜尋套件、儲存庫與 APP 分類

套件詳情v1.1.2

disable_battery_optimization

用於檢查和停用電池優化功能的 Flutter 外掛程式。同時顯示在小米、紅米、三星、OPPO、華為、一加等裝置上停用優化的自訂步驟

Android
近 30 天下載
1.4萬
喜歡數
129
Pub 分數
150

安裝套件

flutter pub add disable_battery_optimization

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 外掛程式,可檢查並停用 Android 裝置上的電池優化功能,特別適用於需要背景執行的應用程式。它為小米、三星、OPPO、華為及一加等知名品牌的裝置提供客製化指示,引導使用者手動設定,確保應用程式運作不受中斷。此外,該外掛程式能透過阻止作業系統限制應用程式活動,提升定位追蹤、推播通知與背景同步等服務的穩定性。

適用情境

  • 背景任務執行
  • 背景位置追蹤
  • 推播通知的可靠性
  • 長時間數據同步
  • 應用性能優化
  • 電池壽命管理

主要特色

  • 設備特定優化指南
  • 自動電池優化檢查
  • 支援主要的安卓品牌
  • 與 Flutter 的簡單整合
  • 清除使用者指示
  • 跨裝置相容性

適合對象

  • 需要持久後台進程的應用
  • 面向 Android OEM 的開發者
  • 需要可靠前臺執行的服務
  • 即時更新的行動應用程式
  • 企業或實用程式應用程式

使用建議

  • 僅需 Android 平台
  • 某些步驟需要使用者互動
  • 限於列出的安卓設備製造商
  • 可能需要權限請求
  • 不適用於 iOS 裝置

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

disable_battery_optimization

Flutter plugin to check and disable battery optimizations. Also shows custom steps to disable the manufacturer specific optimizations on devices like mi, xiaomi, samsung, oppo, huawei, oneplus etc


Auto start
bool isAutoStartEnabled = await DisableBatteryOptimization.isAutoStartEnabled;

This will return true, for the devices which doesn't support auto start configuration as well for the devices on which, user has clicked on positive action for the auto start configuration dialog.

await DisableBatteryOptimization.showEnableAutoStartSettings("Enable Auto Start", "Follow the steps and enable the auto start of this app");

This will show a dialog with steps to enable auto start permission on the current device (if it's available)

Note: We cannot determine if the user has actually enabled the auto start permission or not. We can only show a dialog with the steps to enable.


Android Battery Optimization
bool isBatteryOptimizationDisabled = await DisableBatteryOptimization.isBatteryOptimizationDisabled;

This will return true, only if the user has disabled the 'native' battery optimization for this app.

await DisableBatteryOptimization.showDisableBatteryOptimizationSettings();

This will ask for the permission to disable battery optimization for the app.


Manufacturer specific Battery Optimization
bool isManBatteryOptimizationDisabled = await DisableBatteryOptimization.isManufacturerBatteryOptimizationDisabled;

This will return true, for the devices which doesn't support manufacturer specific battery optimization configuration as well for the devices on which, user has clicked on positive action for the manufacturer specific battery optimization configuration dialog.

await DisableBatteryOptimization.showDisableManufacturerBatteryOptimizationSettings("Your device has additional battery optimization", "Follow the steps and disable the optimizations to allow smooth functioning of this app");

This will show a dialog with steps to disable the manufacturer specific battery optimization on the current device (if it's available)

Note: We cannot determine if the user has actually disabled the manufacturer specific battery optimization or not. We can only show a dialog with the steps to disable it.


There are other helper methods available to check if all the permissions are enabled or disabled.

await DisableBatteryOptimization.isAllBatteryOptimizationDisabled
await DisableBatteryOptimization.showDisableAllOptimizationsSettings

所屬分類

原始碼儲存庫

使用此套件的專案