title: How to capture when have outgoing SMS programmatically on Android?
body: <p>I want to monitor Event "OUTGOING SMS"
  Programmatically?</p>
  
  <p>I have got Event "Incoming SMS" just like this code.</p>
  
  <pre><code>public class IncomingSmsCaptureApp extends BroadcastReceiver {
  private static final String ACTION_NEW_OUTGOING_SMS = "android.provider.Telephony.NEW_OUTGOING_SMS";
  private static final String ACTION_SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
  
  private String action;
  
  @Override
  public void onReceive(Context context, Intent intent) {
      // ---get the SMS message passed in---
      action = intent.getAction();
      if (ACTION_SMS_RECEIVED.equals(action)) {
          Bundle bundle = intent.getExtras();
          SmsMessage[] msgs = null;
          String str = "";
          if (bundle != null) {
              // ---retrieve the SMS message received---
              Object[] pdus = (Object[]) bundle.get("pdus");
              msgs = new SmsMessage[pdus.length];
              for (int i = 0; i &lt; msgs.length; i++) {
                  msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                  str += "SMS from " + msgs[i].getOriginatingAddress();
                  str += " :";
                  str += msgs[i].getMessageBody().toString();
                  str += "\n";
              }
              // ---display the new SMS message---
              Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
          }
      } else {
          onSending(context, intent);
      }
  
  }
  
  public void onSending(Context context, Intent intent) {
      action = intent.getAction();
      if (action.equals(ACTION_NEW_OUTGOING_SMS)) {
          Toast.makeText(context, "Test Capture SMS Sending Success",
                  Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I use this code for monitor Event "OUTGOING SMS".
  It is not work.</p>
  
  <p>My application want to get "Action" when have "OUTGOING SMS".
  Is it possible?
  I didn't find answer for this problem.</p>
  
  <p>Help me please.
  Sorry for my bad English.</p>