1

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?

user434
  • 165
  • 1
  • 9
  • 1
    you have to implement a foreground service to prevent your app from being killed – Vladyslav Matviienko Nov 14 '18 at 08:22
  • i used background service for playing music in background. But this doze mode behavior is in Android 6.0 and above only. @VladyslavMatviienko – user434 Nov 14 '18 at 08:24
  • 1
    you need not a `background` service, but `foreground`? – Vladyslav Matviienko Nov 14 '18 at 08:28
  • ok so foreground services are not affected by doze mode? @VladyslavMatviienko – user434 Nov 14 '18 at 08:50
  • it does not let device to enter doze mode while the foreground service is running – Vladyslav Matviienko Nov 14 '18 at 09:01
  • yes but still there is alot of discussion on this as you see here. https://stackoverflow.com/questions/37869201/how-does-doze-mode-affect-background-foreground-services-with-without-partial-f – user434 Nov 14 '18 at 09:08
  • and you must read this too . https://stackoverflow.com/questions/37834195/mediaplayer-doze-mode-wake-lock-foreground-service whitelsting is needed somehow . So can you answer what my real question is? It will be helpful. @VladyslavMatviienko – user434 Nov 14 '18 at 09:13
  • I don't think I must read anything, I'm OK with what I know. It works for me – Vladyslav Matviienko Nov 14 '18 at 09:17
  • well what i think , you also have to add broad cast receiver for check, in case your service is destroyed then you can again start the service – Abdul Kawee Nov 14 '18 at 10:39
  • you can read more about different types of permissions in android system. safe and dangerous. if this permission comes under safe permission you dont need to add. – Developine Nov 14 '18 at 10:39

0 Answers0