So im making an app that uses sms to send data between two devices and am trying to get one to automaticly respond to the other. But the string getMessageBody() is returning isnt setting of the if statment to send the automatic message even tho the log output "(test)" seems to match the condition. I have added extra text to either side of the string in the log message to check for whitespace. Thanks in advance.
The code sending the message to be received.
SendSMS(inputNum.getText().toString(),"test");
The receiver code
public void onReceive(Context context, Intent intent)
{
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
if(bundle != null)
{
Object[]pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for(int i = 0;i < msgs.length;i++)
{
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
originNumber = msgs[i].getOriginatingAddress();
messages = msgs[i].getMessageBody();
Log.e("Received Text", messages);
}
if(messages == "test")
SendSMS(originNumber, "auto send");
else
Log.e("else Text", "("+messages+")");
}