I am having a BroadcastReceiver class which reads incoming sms and extracting a pin from the sms.
I want to pass that sms to an activity which is already visible to user.
User should enter the pin in an EditText, I am taking the value from the EditText in , Compare the Pin entered by the user with the Pin passed by the BroadcastReceiver. 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 BroadcastReceiver into the Activity.
Here is the code
BroadcastReceiver class
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 < 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);
}
}