title: Android application IF statement isn't behaving as expected
body: <p>So I'm working on this Android application, and for some reason that I've spent multiple hours trying to fix and is probably some stupid mistake, but for some reason the code isn't working when it gets to the if statement. When I send a message such as "hello" the toast message that pops up with the length of the message and sender says 5 and 10, for the 10 digit phone number. However, when it gets to the if statement, it doesn't act as if it's equal. Any help would be much appreciated. Here's my code </p>
  
  <pre><code>public class SmsReceiver extends BroadcastReceiver {
  
  @Override
  public void onReceive(Context context, Intent intent) {
      String msg_from = null;
      String msgBody = null;
        if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")){
              Bundle bundle = intent.getExtras();           //---get the SMS message      passed in---
              SmsMessage[] msgs = null;
  
              if (bundle != null){
             //   Toast.makeText(context, "SMS Received", Toast.LENGTH_LONG).show();
                  //---retrieve the SMS message received---
                  try{
                      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]);
                          msg_from = msgs[i].getOriginatingAddress();
                           msgBody = msgs[i].getMessageBody();
                           msgBody = msgBody.trim();
                           msg_from = msg_from.trim();
  
  
  
                      }
                  }catch(Exception e){
                              Log.d("Exception caught",e.getMessage());
                  }
              }
          }
        Toast.makeText(context, "MsgBody length: " + msgBody.length() + "msg_from          length: " + msg_from.length(), Toast.LENGTH_LONG).show();
        if (msgBody.length() == 5){
            Toast.makeText(context, "Working", Toast.LENGTH_LONG);
        }
  }
  </code></pre>
  
  <p>}</p>