how to stop telephone ringing when get call, but not mute it globally

android

Solution

Could you just mute on the ringer stream when the phone is in a state of ringing and then turn it back on once the ringing has finished. You can use a content observer to check on the current state of the phone. I think from ICS onwards that the ringtone and notification sounds are all played on the same stream I can't think of another way to do this. It does mean you'll get no sound on for notifications while the phone is ringing.

audioManager.setStreamMute(AudioManager.STREAM_RING, true);

Problem

I know how to mute sound globally when phone is ringing: ``` AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); ``` but i would like to mute phone ringing without make it SILENT globally. Like if you click sound button on the phone and it stops ringing. How would i do this programmatically?

Original source