Receive only sms of a particular format by my application
<p>I am using Brodcast Receiver class to receive sms by my application. I have also given priority to my application in manifest file. I have coded in my application that if a sms is in a particular format then it should load a second screen. It runs fine when sms is of particular format but when i send in any other format since my application has been given higher priority it receives sms first(my assumption) then it generates force close dialog box but the message shows in the notification bar. </p>

<p>What i want is if a sms is of particular format then it should be handled by my application else it should be handled by system ?</p>

<p>My main file is :</p>

<pre><code>package com.example.smsapp;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;




public class SMSApp 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&lt;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();
        String[] msgText;
        msgText=str.split(",");
        if(msgText[0].equals("second"))
        {               
            Intent i = new Intent(context,Second.class);
            i.putExtra("msg",msgText[1]);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);   
            context.startActivity(i);
        }

    }
    this.abortBroadcast();
}



 }
</code></pre>

<p>Manifest file:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.demo.smsapp" android:versionCode="1"
android:versionName="1.0"&gt;
&lt;uses-sdk android:minSdkVersion="8" /&gt;

&lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
    &lt;activity android:name="Second" class=".second"
        android:label="SMSApp"&gt;
    &lt;/activity&gt;
    &lt;receiver android:name=".SMSApp"&gt;
        &lt;intent-filter android:priority="100"&gt;
            &lt;action android:name="android.provider.Telephony.SMS_RECEIVED" /&gt;
        &lt;/intent-filter&gt;
    &lt;/receiver&gt;
&lt;/application&gt;
&lt;uses-permission android:name="android.permission.SEND_SMS"&gt;
&lt;/uses-permission&gt;
&lt;uses-permission android:name="android.permission.RECEIVE_SMS"&gt;
&lt;/uses-permission&gt;
&lt;/manifest&gt;
</code></pre>
