Deleting an sms from a particular number in Android

For deleting an sms from a particular number.
Here we have to use a Broadcast receiver. When an sms is receiving, this broacast receiver will invoked.
So our manifest will look like this,

<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />

<receiver android:name="Receiverdetectsms" android:permission="android.permission.BROADCAST_SMS" >
<intent-filter android:priority="999" >
    <action android:name="android.provider.Telephony.SMS_RECEIVED" />

And (Broadcast receiver) "Receiverdetectsms"  will look like,
public class Receiverdetectsms extends BroadcastReceiver {

public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
if (bundle != null) {
/* Retrieve the SMS. */
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i = 0; i < msgs.length; i++) {
msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
if (msgs[i].getOriginatingAddress().indexOf("9447024365") != -1) {
abortBroadcast();//delete sms from 9447024365


Popular posts from this blog

Async Task in Android

Shake effect in Android

Example For ListView Using BaseAdapter