I am developing an app which needs to perform particular action on the exact time which user has set. For this i am using setExactAndAllowWhileIdle() method bec
Some addition to @MarGin's answer.
It's much easier for user to do all in one dialog but this violates the Google Play policy
if (!powerManager.isIgnoringBatteryOptimizations(packageName)) {
startActivity(
Intent(
Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS,
Uri.parse("package:$packageName")
)
)
}