Selective Silent Mode
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"