tags:

views:

67

answers:

1

i have broadcast receiver class for receiving sms, but i dont know how to delete the received sms before reaching to the inbox as well as the notification

public void onReceive(Context context, Intent intent) {     

        Bundle pudsBundle = intent.getExtras();     
        Object[] pdus = (Object[]) pudsBundle.get("pdus");
        SmsMessage messages =SmsMessage.createFromPdu((byte[]) pdus[0]);        
        Log.i(TAG,  messages.getMessageBody());
}
A: 

In your intent filter you should set the priority higher than the systems SMS-application.

<intent-filter android:priority="100" ...

And then in your broadcast receiver you call abortBroadcast()

   public void onReceive(Context context, Intent intent) {
     //... 
     abortBroadcast();
   }
MatteKarla
Won't this stop ALL broadcasts? he should have if intent.action().equals("WhateverTheActionIsCalled")
AndrewKS
Arun: Do you have a custom SMS-application installed? If that application have higher priority than your intent filter then they will recieve it first. try increasing the priority. Also if you don't return from `onRecieve()` quickly it could continue to the next broadcast reciever.
MatteKarla
Thanks MatteKarla . your solution is working fine .
Arun