0

Possible Duplicate:
Detecting SMS incoming and outgoing

i want to read an incoming sms to check perticular value exist in sms

i found this sms reciving code i want to check if reciving sms have following value xml values

plz help me how i check

//this is response which i check in reciving sms

00
LOG
00
Adeel Aslam
10.00
10/05/2012 10:00
+100


//this is code which i found for sms recive
     public class SmsReceiver extends BroadcastReceiver
  {
@Override
public void onReceive(Context context, Intent intent) 
{
    //---get the SMS message passed in---
    Bundle bundle = intent.getExtras();        
    SmsMessage[] msgs = null;
    String str = "";            
    if (bundle != null)
    {
        //---retrieve the SMS message received---
        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]);                
            str += "SMS from " + msgs[i].getOriginatingAddress();                     
            str += " :";
            str += msgs[i].getMessageBody().toString();
            str += "\n";        
        }
        //---display the new SMS message---
        Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
    }   

} 
Community
  • 1
  • 1
Christina Ayers
  • 97
  • 1
  • 1
  • 5

1 Answers1

0

You can use contains() method to check if specific word is present in the sms or not.

 if(str.contains("LOG"))
  {
    // Perform your task here.
   }
Akshay
  • 2,506
  • 4
  • 34
  • 55