I do not think that you want to do telephonyService.endCall() in getTeleService() . You probably want to call this instead of the onReceive method.
I'm not sure if you want to reject all calls or just one of the specific numbers. If you are only trying to reject certain numbers, it looks like you do not have a code to check the number of an incoming call to blocked numbers after receiving it:
public void onReceive(Context context, Intent intent) { Bundle b = intent.getExtras(); incommingNumber = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER); --->
You can try changing it to the following if you want to check the number and reject calls only from blocked numbers:
public void onReceive(Context context, Intent intent) { Bundle b = intent.getExtras(); incommingNumber = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
Or, if you just want to reject all calls, it's even simpler:
public void onReceive(Context context, Intent intent) { telephonyService.endCall(); }
source share