Search packages, repositories and app categories

GitHub repositoryBhat015/optimize_battery

optimize_battery

Flutter plugin to check for battery optimization status, open optimization settings and disable optimization.

optimize_battery project cover
Stars
10
Forks
19
Last push (UTC)
Mar 13, 2024
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

optimize_battery

Check for application battery optimization status and open settings or disable it

Getting Started

Check if app is ignoring battery optimization

  OptimizeBattery.isIgnoringBatteryOptimizations().then((onValue) {
      setState(() {
          if (onValue) {
              // Igonring Battery Optimization
          } else {
              // App is under battery optimization
          }
      });
  });

Take user to battery optimization settings

  OptimizeBattery.openBatteryOptimizationSettings()

Show battery optimization disable dialog

  OptimizeBattery.stopOptimizingBatteryUsage();

This opens the battery optimization disable dialog.

Example

Add the permission in Mainfest file

<uses-permission  android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>

It uses the intent(ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS). Which is not recommended unless its an excemtion case. Such as the applications main functionality needs the battery optimisation to be disabled.

Read more here : https://developer.android.com/training/monitoring-device-state/doze-standby#exemption-cases

Credit

This plugin is inspired from battery_optimization but with supporting Null safety and Android V2 embedding

Ganesh Bhat GitHub avatar
GitHub author

Ganesh Bhat ↗

Bengaluru
LanguagesDartJavaRubySwiftObjective-C

Packages published by this repository

Dependencies used

Dependency list 3 items

  • flutter{"sdk":"flutter"}
  • flutter_testDevelopment{"sdk":"flutter"}
  • flutter_lintsDevelopment^1.0.0

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗