Reputation: 1177
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());
}
Upvotes: 3
Views: 8185
Reputation: 4569
<receiver android:name=".SMSReceiver"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="999" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
and in receiver
public void onReceive(Context context, Intent intent) {
//...
abortBroadcast();
}
This will work fine.
Upvotes: 1
Reputation: 2737
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();
}
Upvotes: 12