Giter Club home page Giter Club logo

batterypermissionhelper's Introduction

BatteryPermissionHelper

License: MIT Android Build Unit Tests API

An Android Library to detect battery optimizations settings and navigate the user to the relevant screens so that they can whitelist the app. This will prevent the app from getting killed in the background due to Battery Optimization Managers. The library supports multiple OEMs.

Installation

Gradle

Add this to your module's build.gradle file:

dependencies {
    // ... other dependencies
    implementation 'com.waseemsabir:betterypermissionhelper:1.0.3'    
}

Maven

<dependency>
    <groupId>com.waseemsabir</groupId>
    <artifactId>betterypermissionhelper</artifactId>
    <version>1.0.3</version>
</dependency>

Other instructions for installation can be viewed here.

Usuage

private val batteryPermissionHelper = BatteryPermissionHelper.getInstance()

// check whether or not Battery Permission is Available for Device
val isBatteryPermissionAvailable = batteryPermissionHelper.isBatterySaverPermissionAvailable(context = context, onlyIfSupported = true)

// Show a dialog based on availability (Implementation left to Dev) and OnClick open permission manager
dialog.setOnClickListener {
    batteryPermissionHelper.getPermission(this, open = true, newTask = true)
}

To keep the library small and extendable, UI elements (dialog/popups) implementation is left up to the library user. The library will not show any screens.

Currently, the library supports following devices.

  1. Xiaomi
  2. Redmi
  3. Poco
  4. Letv [ Untested ]
  5. HTC [ Untested ]
  6. Huawei
  7. Oppo
  8. Samsung
  9. ZTE [ Untested ]
  10. Meizu [ Untested ]

I am open to any PR's and contributions for any devices. I'll also try to add more devices, whenever possible.

Relevant Work

batterypermissionhelper's People

Contributors

mkckr0 avatar waseemsabir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

batterypermissionhelper's Issues

Checking if a specific permission is already set

Is your feature request related to a problem? Please describe.
If it's possible to know if the user already set the permission for "No restriction" for example on Miui and getting the results back

Describe the solution you'd like
A string/enum for understanding if the set the wanted permission

Describe alternatives you've considered
The alternative is just to believe the user if he set the desired permission

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.