title: How to pass data from BroadcastReceiver to an Activity?
body: <p>I am having a <code>BroadcastReceiver</code> class which reads incoming <code>sms</code> and extracting a pin from the <code>sms</code>.
  I want to pass that <code>sms</code> to an activity which is already visible to user.
  User should enter the pin in an <code>EditText</code>, I am taking the value from the <code>EditText</code> in , Compare the Pin entered by the user with the Pin passed by the <code>BroadcastReceiver</code>. If both match to each other, user can go into the app.But I don't know how to pass that Pin received by the <code>BroadcastReceiver</code> into the <code>Activity</code>.
  Here is the code</p>
  
  <p><strong>BroadcastReceiver class</strong></p>
  
  <pre><code>public class IncomingMessage extends BroadcastReceiver {
  
  final SmsManager sms = SmsManager.getDefault();
  private OnSMSReceived onSMSReceived = null;
  
  @Override
  public void onReceive(Context context, Intent intent) {
  
      // Retrieves a map of extended data from the intent.
      final Bundle bundle = intent.getExtras();
  
      try {
  
          if (bundle != null) {
  
              String senderNum = null;
              String message = null;
              final Object[] pdusObj = (Object[]) bundle.get("pdus");
  
              for (int i = 0; i &lt; pdusObj.length; i++) {
  
                  SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
                  String phoneNumber = currentMessage.getDisplayOriginatingAddress();
  
                  senderNum = phoneNumber;
                  message = currentMessage.getDisplayMessageBody();
  
                  Log.i("SmsReceiver", "senderNum: " + senderNum + "; message: " + message);
  
              }
  
              if (senderNum.equals("ideamart")) {
                  Log.d("MessageIdeaMart", message);
  
              } else if (senderNum.equals("FindDroid")) {
                  if (message.startsWith("Welcome")) {
                      String[] splitArray = message.split(" ");
                      String pin = splitArray[7];
                      Log.d("PIN", pin);
  
                  }
              }
          }
      } catch (Exception e) {
          Log.e("SmsReceiver", "Exception smsReceiver" + e);
  
      }
  }
  
  
  public void setOnSmsReceivedListener(Context context) {
      this.onSMSReceived = (OnSMSReceived) context;
  }
  
  
  public interface OnSMSReceived {
      void onSMSReceived(String pin);
  }
  </code></pre>
  
  <p>}</p>