Skip to content Skip to sidebar Skip to footer

Selective Silent Mode

I had developed an app which will selectively rings for certain numbers even if the phone is in silent mode.I had written the code for making it louder in a broadcast receiver. T

Solution 1:

Your BroadcastReceiver is doing too much. It only lives as long as its onReceive() method, so you're not getting all the functionality you are putting into it. Try moving your volume manipulation code into a Service, and use the BroadcastReceiver as a simple proxy to tell the Service when a call is incoming. You should generally avoid heavy operations from within the context of a BroadcastReceiver.

Also, just calling setRingerMode(AudioManager.RINGER_MODE_NORMAL) is not always sufficient to un-silence the ringer. You will also need to call setStreamMute(AudioManager.STREAM_RING, false) and setStreamVolume(AudioManager.STREAM_RING, someAudibleVolume, 0). On many devices, the ringer mode can be "normal" while the ringer volume is "0".

BTW I have written an app very similar what you describe, and will wish you luck :). You will see some of the worst fragmentation in the Android device ecosystem when trying to manipulate the ringer volume consistently. e.g. on a Samsung Galaxy Nexus, you can easily override and manipulate the volume after an incoming call starts. Yet on a Galaxy S3 the ringer volume ignores attempts to change it while a call is incoming, and requires some clever (read "hackish") workarounds.

Post a Comment for "Selective Silent Mode"