What is important :

abortBroadcast();
filter.setPriority(1000);

It works (I use in my app GPSDetective - you can dl on the android market)

Sample code :


    BroadcastReceiver br;

    @Override
    public void onCreate()
        {
        super.onCreate();

        br = new BroadcastReceiver()
            {
            @Override
            public void onReceive(Context ctx, Intent intent)
                {
                Bundle extras = intent.getExtras();
                SmsMessage[] sms = null;
                if (extras != null)
                    {
                    //read the content of the SMS and do what you want
                    if (bKeepThisSMSforMyApp=true)
                        abortBroadcast();
                    }
                }
            };
        IntentFilter filter = new IntentFilter();
        filter.addAction("android.provider.Telephony.SMS_RECEIVED");
        filter.setPriority(1000);
        registerReceiver(br, new IntentFilter(filter));
        }

Le 15/05/2012 14:23, Farhan Tariq a écrit :
I am really stuck at this. Someone please guide me. Thanks

On Tue, May 15, 2012 at 2:47 AM, Farhan Tariq <[email protected] <mailto:[email protected]>> wrote:

    Hi all,

    I aim to make an app that would store sms messages with certain
    words contained in an sms, and stop it from reaching the default
    messaging app. I realize that I need to place a broadcast receiver
    for sms messages in my app, but how do I ensure that If a message
    contains a KEYWORD, the message gets deleted immediately and
    becomes unaccessible to any other messaging app? I am stuck here,
    so any help is appreciated. Thank you

    Regards,

    Farhan


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to