1

I want to silence the ring when there is an incoming call, and I setup a button to do a test like this:

silenceButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        ITelephony iTelephony = getITelephony();
        try {
            iTelephony.silenceRinger();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
});

but the ring is not silenced when I click the button and the logcat outputs an error:

PhoneInterfaceManager: silenseRinger not supported

I think my getITelephony() is working correctly because I can decline the incoming call based on it:

declineButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        ITelephony iTelephony = getITelephony();
        try {
            iTelephony.endCall();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
});

So why android stops supporting for silence the incoming call? Is there another way to do this?

1 Answers1

0

Another solution would look something like this:

android.permission.MODIFY_AUDIO_SETTINGS

AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
//silent mode
audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);

Read these other questions for more info:

Petro
  • 3,484
  • 3
  • 32
  • 59
  • Thanks for your code, that works! by the way, do you know why the android system won't support silenseRinger() method which is more convenient? – Stanley Nian Oct 18 '19 at 02:55
  • I'm not sure, the docs didn't state why it was removed. BTW please mark this answer correct if it solved your issue. Thanks! – Petro Oct 18 '19 at 15:40