When my online radio application goes in doze mode there is no network access because of which the radio stops working.Even the wake locks don't work in doze mode. I've added the intent as per qouted in documentation.
An app holding the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission can trigger a system dialog to let the user add the app to the whitelist directly, without going to settings. The app fires a ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Intent to trigger the dialog.
Here is the intent.
Intent myIntent = new Intent();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
myIntent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
myIntent.setData(Uri.parse("package:" + getPackageName()));
startActivity(myIntent);
}
also i have added permission in manifest because the intent is not working without it. Is it safe to use this permission in a radio application?