Search code examples
androidbroadcastreceiver

Block incoming call instantly in Android


In my application I want to put a feature for blocking incoming calls.

For this I refereed this link

And its work perfectly but it takes nearly 2 seconds to end the call not instantly.

And at caller side a tune of The person your calling busy at the movement gets listen.

Is it possible to end the call without ringing?


Solution

  • Try this in your code.

    @Override
    public void onReceive(Context context, Intent intent) 
    {
        String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        setResultData(null); //It will terminate the call
        Toast.makeText(context, "Call Terminated" + number, 5000).show();
    }