-
-
Save virendersran01/79ea6bef01eb29d684f4d696c00c74f5 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