Block an incoming call without a call, even for a fraction of the second android

I used the following code:

Problem: It works fine and blocks an incoming call, but the phone ring is for a split second before disconnecting the call . could there be a solution i'm looking for.

public class CallReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle b = intent.getExtras(); incomingNumber1 = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER); TelephonyManager telephony = (TelephonyManager)context .getSystemService(Context.TELEPHONY_SERVICE); Class c = Class.forName(telephony.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony"); m.setAccessible(true); telephonyService = (ITelephony) m.invoke(telephony); telephonyService.endCall(); }} 

I have not yet found the answer to the question. I want the solution to work perfectly on Android 2.3. An incoming call must be completely blocked, there should be no call.

+4
source share

Source: https://habr.com/ru/post/1380355/


All Articles