title: Android SMS Listener for specific number
body: <p>I am writing an application that communicates with other devices through SMSs.</p>
  
  <p>I was able to implement a listener for received SMSs. The thing is that it is listening to all received messages. I would like to only listen received SMSs from a specific number.</p>
  
  <p>Here is my <code>onReceive</code> method.</p>
  
  <pre><code>@Override
  public void onReceive(Context context, Intent intent) {
      // TODO Auto-generated method stub
      Bundle bundle = intent.getExtras();
  
      Object messages[] = (Object[]) bundle.get("pdus");
      SmsMessage smsMessage[] = new SmsMessage[messages.length];
      for (int n = 0; n &lt; messages.length; n++) {
          smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
      }
  
      // show first message
      Toast toast = Toast.makeText(context,
                    "Received SMS: " + smsMessage[0].getMessageBody(),
                    Toast.LENGTH_LONG);
      toast.show();
  }
  </code></pre>