Created
July 1, 2020 09:19
-
-
Save MrCrambo/fa81999e7fa51f61bf3809150df4e4db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
Intent intent = new Intent(); | |
String packageName = getPackageName(); | |
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); | |
if (!pm.isIgnoringBatteryOptimizations(packageName)) { | |
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); | |
intent.setData(Uri.parse("package:" + packageName)); | |
startActivity(intent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment