title: Android BroadCastReceiver and android.intent.action.PHONE_STATE Event
body: <p>I am catching the android.intent.action.PHONE_STATE change event by using following code snippet with android BroadCastReceiver. I could recognize the event successfully and handle the incoming calls also can be done by following code.</p>
  
  <p>My requirement is identifying calls which are coming form a particular number, end that call through the code and invoke a web service for that incoming event.</p>
  
  <p>In here this code runs twice for call receiving and ending events. </p>
  
  <p>I want to stop calling this method for twice. How can i stop calling that code snippet for the second event (ending the call). It would be great-full if any one can help me on this.</p>
  
  <pre><code> if (intent.getAction().equals(
              "android.intent.action.PHONE_STATE")) {
          Log.i("INFO", "Call Received");
  
          try {
  
              TelephonyManager telephony = (TelephonyManager) context
                      .getSystemService(Context.TELEPHONY_SERVICE);
  
              Bundle bundle = intent.getExtras();
  
              Log.i("Calling database", "Creatinng DataHandler Object");
              DatabaseHandler db = new DatabaseHandler(context);
              String phoneNumber =db.getContact().getPhoneNumber();
  
              Log.i("Retriving : ", "Retriving .."+ db.getContact().getPhoneNumber());
  
  
              if ((bundle.getString("incoming_number").equals(phoneNumber))) {
  
                  Log.i("Test Call", "This is the test call");
  
                  @SuppressWarnings("rawtypes")
                  Class c = Class.forName(telephony.getClass().getName());
                  Method m = c.getDeclaredMethod("getITelephony");
                  m.setAccessible(true);
  
                  ITelephony telephonyService = (ITelephony) m
                          .invoke(telephony);
                  telephonyService = (ITelephony) m.invoke(telephony);
  
  
                  telephonyService.endCall();
  
                  // Call the web service and send log details
  
                  ServiceClient sc = new ServiceClient();
                  sc.serviceCall(context);
  
  
              } else {
                  Log.i("Normal Call", "This is not the test call");
              }
  
          } catch (Exception e) {
              Log.i("Exception Occured", "Exception in call code snipet");
          }
      }
  </code></pre>
  
  <p>}</p>