1

I wrote an Android application, that changes the ringer mode from any mode to normal, if a BroadcastReceiver receives a notification.

It's working fine on Android < 8.

It also works for my Android 8 device, if ringer mode != silent when the broadcast receiver reacts.

  • ringer mode != silent & change it to any ringer mode
    • works on all devices
  • ringer mode == silent & change it to silent mode
    • works fine on all devices
  • ringer mode == silent & change it to non-silent mode
    • works only on older devices with Android < 8

When changing from silent to non-silent on Android 8, I get an exception saying Boradcast already finished?!

This behavior is only on my Android 8 device, older devices work fine.

Can someone help on this strange behavior? Thank you!

Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
D. Müller
  • 3,336
  • 4
  • 36
  • 84

1 Answers1

0

I found the solution for the issue: It's caused by the "Do not disturb" mode in newer Android versions.

To disable this silent-mode you have to

  1. add permission to AndroidManifest:

    uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"

  2. Ask the user to allow to leave this do-not-disturb mode by the following intent:

    Intent intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS); startActivity(intent);

See also this question/answer: In Android 7 (API level 24) my app is not allowed to mute phone (set ringer mode to silent)

D. Müller
  • 3,336
  • 4
  • 36
  • 84