title: Creating a SMS Application in Android?
body: <p>I am creating an SMS Application to send and receive SMS. </p>
  
  <p>I am able to send SMS using the following code:</p>
  
  <pre><code>SmsManager sms = SmsManager.getDefault();
  sms.sendTextMessage(phoneNumber, null,message , pi, null); 
  </code></pre>
  
  <p>I would like to receive SMS and put them in my own inbox. How do I create this inbox? I would like it to work the same way as a normal inbox.</p>
  
  <pre><code>Bundle bundle = intent.getExtras();     
  Object[] pdus = (Object[]) bundle.get("pdus"); 
  SmsMessage[] messages = new SmsMessage[pdus.length];    
  for (int i = 0; i &lt; messages.length; i++) {
  
      messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]); 
      Log.v("SMSFun","Body: " + messages[i].getDisplayMessageBody());
      Log.v("SMSFun","Address: " + messages[i].getDisplayOriginatingAddress());   
      //If say we wanted to do something based on who sent it       
      if (messages[i].getDisplayOriginatingAddress().contains("5556")) {
  
          // we could launch an activity and pass the data   
          Intent newintent = new Intent(ctx, SecretMessage.class);    
          newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          newintent.putExtra("address", messages[i].getDisplayOriginatingAddress());
          newintent.putExtra("message", messages[i].getDisplayMessageBody());
          ctx.startActivity(newintent);
      }
  }
  </code></pre>
  
  <p>How do I store incoming SMS in the inbox?</p>
  
  <p>Is it possible in Android to listen to particular port number for SMS?</p>