In Android I need to get notified when the current audio mode gets changed.
I can get this value through getMode() but this is polling.
I don't want to poll every few seconds.
What are my options?
(Please note that I'm not asking about ringerMode)
You can use AudioFocus for devices running Android OS version 2.2 and higher, preassuming your app is also playing audio.
You can register for audio focus changes and then listen onAudioFocusChange(int focusChange)
method. By this way you will be notified of audio mode changes as well as other audio focus changes. I hope this helps.
You can also use PhoneStateListener to listen phone states changes and corresponding audio modes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With