How to block a call programmatically in android

Possible duplicate:
How to block calls in android

I am developing an application in Android 2.2 that receives the status of the phone and checks if the incoming number is in the blacklist table, which should block this particular number. For this, I use this code:

TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); Class c = Class.forName(tm.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony"); m.setAccessible(true); com.android.internal.telephony.ITelephony telephonyService = (com.android.internal.telephony.ITelephony) m.invoke(tm); telephonyService.silenceRinger(); telephonyService.endCall(); 

Everything is going well, but sometimes my phone rings for a second before disconnecting this call.

Please help me if there is any other way to do this, or I need to change my code to disable the blacklist.

Thanks in advance.

+4
source share
1 answer

I think you should refer to this question . It can help you do whatever you want.

+2
source

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


All Articles