title: Block Incoming calls in android without single ring
body: <p>Though this code i am able to block incoming calls but problems it rings for fraction of seconds before disconnection of time how can i directly disconnect phone without single ringing. </p>
  
  <pre><code>public class IncomingCallsReceiver extends BroadcastReceiver {
  private Context context;
  private static int CALLSHIELD_ID = 1982;
  private static final String TAG = "Phone call";
  private ITelephony telephonyService;
  
  @Override
  public void onReceive(Context context, Intent intent) {
      Log.i("Log","coming");
      this.context = context;
      String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
      if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
          TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
          Bundle bundle = intent.getExtras();
          String incomingNumber = bundle.getString("incoming_number");
          Cursor cursor;
          if (G.savePreferences.getString("modef", "0").equals("0")) {
              switch (G.savePreferences.getString("mode", "2")) {
                  case "0":
                      break;
                  case "1":
                      try {
                          Class c = Class.forName(telephony.getClass().getName());
                          Method m = c.getDeclaredMethod("getITelephony");
                          m.setAccessible(true);
                          telephonyService = (ITelephony) m.invoke(telephony);
                          telephonyService.endCall();
                              G.lDbHeper.setlog(incomingNumber, time(), date());
                          if (G.savePreferences.getString("notification", "false") == "true") {
                              showNotification(incomingNumber);
                          }
  
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
  
                      break;
              }
          }
      }
  }
  </code></pre>