title: How to block a call programmatically in android
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1083527/how-to-block-calls-in-android">How to block calls in android</a>  </p>
  </blockquote>
  
  
  
  <p>I am developing an app in Android 2.2 which gets the phone state and checks if the incoming number is in blacklist table than it has to block that particular number.for this i am using given code:</p>
  
  <pre><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();
  </code></pre>
  
  <p>All is going well but sometime my phone rings for a second before disconnect that call.</p>
  
  <p>Please help me out if there is any other way to do this or should i modify my code to silently disconnect the blacklist call.</p>
  
  <p>Thanks in advance. </p>