Incoming Call Blocking in Android

后端 未结 1 487
庸人自扰
庸人自扰 2021-02-10 19:02

I am able to block incoming calls in android but problems it rings for fraction of seconds before disconnection of time. How can i directly disconnect phone without single ringi

1条回答
  •  心在旅途
    2021-02-10 20:05

    It is Mission Impossible for the time being. Viewing the reason here : Why it is impossible to intercept incoming calls on Android

    But I suggest you still a temporary solution I myself adopted :

    Before to block the call, the first thing you need to do is retrieve the current mode of the phone ringing, and then turn on silent :

    AudioManager audiomanage = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
    int ringerMode = audiomanage.getRingerMode();
    audiomanage.setRingerMode(AudioManager.RINGER_MODE_SILENT);
    

    After blocking the call (or not) gives you the initial mode :

    audiomanage.setRingerMode(ringerMode);
    

    You'll need these permissions :

    
    
    
    

    I hope I helped you.

    0 讨论(0)
提交回复
热议问题