Skip to content Skip to sidebar Skip to footer

Filter Sms From A Specified Numbers And Display

Is it possible in android to filter the SMS from a specific number in android.And save it in a specific database.and the SMS should not be visible in the inbox...

Solution 1:

You have yo do this in 3 step:

  1. read SMS from Specific number you have to look in to this link then after
  2. you have to create Database for store all info about SMS(like id, body, number, time) for that check this link
  3. you have to Delete SMS from INBOX check this link for delete SMS.

add below permission for do all step:

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

Solution 2:

ya is it possible.

in mainfest file add following code:

<receiverandroid:name="com.example.Sms_BReceiver" ><intent-filter><actionandroid:name="android.provider.Telephony.SMS_RECEIVED" /></intent-filter></receiver></application><uses-permissionandroid:name="android.permission.RECEIVE_SMS" /><uses-permissionandroid:name="android.permission.READ_SMS" />

after that create a class use following code

publicclassSms_BReceiverextendsBroadcastReceiver {

    @OverridepublicvoidonReceive(Context context, Intent intent) {
         Bundle bundle = intent.getExtras();
         SmsMessage[] messageString = null;

        Object[] pdus = (Object[]) bundle.get("pdus");
        messageString = newSmsMessage[pdus.length];
                    for (i = 0; i < messageString.length; i++) {
          messageString[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                    }

        Phone_no = messageString[0].getOriginatingAddress();
        Message_body = messageString[0].getMessageBody();
        Time = messageString[0].getTimestampMillis();

        CharSequence text = str;
        Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
    }


    if (Phone_no.contains(here check no to filter) {
             here delete message form inbox 
             and save in our own db 

    } else  {

    }


 }

i hope this code will use full for u

Post a Comment for "Filter Sms From A Specified Numbers And Display"