Activity need to be started before receiving sms from Particular number or port
<p>Hi 
How can i start an activity (UI) after receiving and parsing the sms?
I tried the article at <strong>http://www.anddev.org/recognize-react_on_incoming_sms-t295.html</strong>
but still  the activity is starting before we send the sms and then after when i send the sms i am only able to see the received notification.So please help me to start the activity only after receiving SMS.
Here is the code what i am using</p>

<pre><code>import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import android.os.Bundle;
import android.telephony.gsm.SmsMessage;
import android.util.Log;
import android.widget.Toast;

public class SmsReactor extends BroadcastReceiver {


        private static final String LOG_TAG = "SMSReactor";

        private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";

@Override
public void onReceive(Context context, Intent intent) 
{
    if (intent.getAction().equals(ACTION)) 
    {

                          StringBuilder sb = new StringBuilder();

                            Bundle bundle = intent.getExtras();
            if (bundle != null) 
            {                                                                   
                    Object[] pduObj = (Object[]) bundle.get("pdus");            
                    SmsMessage[] messages = new SmsMessage[pduObj.length];                                  
                    for(int i=0;i&lt;pduObj.length;i++)
                    {                                   
                        messages[i]=SmsMessage.createFromPdu((byte[])pduObj[i]);
                    }                       

                    for (SmsMessage currentMessage : messages)
                    {                       
                        sb.append("SMS Received From: ");                       

                        sb.append(currentMessage.getDisplayOriginatingAddress());                   
                        sb.append("\nMessage : ");                  
                        */                      
                        sb.append(currentMessage.getDisplayMessageBody());                  
                    }

          }                             

           Log.i(LOG_TAG, "[SMSApp] onReceive: " + sb);                                
           /* Show the Notification containing the Message. */             
            Toast.makeText(context, sb.toString(), Toast.LENGTH_LONG).show();              
              /* Start the Main-Activity */ 

            Intent i = new Intent(context, SmsActivity.class);              
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);              
            context.startActivity(i);

    }       
}
}
</code></pre>

<p>So please help me out of this situation its urgent
thanks in advance</p>
