0

I'm trying to make an simple application to intercept all SMS received from my telephone operator's e-mail service.

How it works: I have an e-mail from my telephone operator's that notifies me every time that an e-mail comes to the inbox with a SMS. The SMS comes that way:


You have a new e-mail from:email@domain.com See it now through internet! Visit http://m.iclaro.com.br. Subject: SUBJECT GOES HERE

This app that i'm trying to make have to intercept these SMS, retrieve the entire subject ("SUBJECT GOES HERE") and send a fake SMS from a number with only the subject on its contents.

What I've already done: intercept all these SMS from this e-mail service, retrieve the subject and fake a new SMS from a new number (I've choosen 3) just with the subject.

But now I have a problem: this new faked SMS doesn't show any notification.

Here goes the BroadcastReceiver:


public class SmsReceiver extends BroadcastReceiver
    {
        ...
        public void onReceive( Context context, Intent intent ) 
        {
            ...
            if(address.contains("1") && body.contains(replace))
            {                   
                    body = body.substring(body.lastIndexOf(replace),body.length());
                    body = body.replace(replace, "");
                    address = "3";

                    ContentResolver contentResolver = context.getContentResolver();
                    ContentValues values = new ContentValues();
                    values.put("address", address);
                    values.put("body", body);
                    contentResolver.insert(Uri.parse("content://sms/inbox"), values);
                    this.abortBroadcast();
            }
        }
    }

I had also tried to:


if(address.contains("1") && body.contains(replace))
{
    this.abortBroadcast();

and

contentResolver.insert(Uri.parse("content://sms/inbox"), values);
this.abortBroadcast();

and

this.clearAbortBroadcast();
contentResolver.insert(Uri.parse("content://sms/inbox"), values);
this.abortBroadcast();

Is there anyway to re-notify the last received SMS? Any suggestions?

BenMorel
  • 34,448
  • 50
  • 182
  • 322

1 Answers1

0

You will have to encode pdu after editing the received sms message. For that you can use java libraries like smslib etc. for encoding pdu.

public class SmsReceiver extends BroadcastReceiver
    {
        ...
        public void onReceive( Context context, Intent intent ) 
        {
            ...
            if(address.contains("1") && body.contains(replace))
            {                   
                    body = body.substring(body.lastIndexOf(replace),body.length());
                    body = body.replace(replace, "");
                    address = "3";

                    //ContentResolver contentResolver = context.getContentResolver();
                    //ContentValues values = new ContentValues();
                    //values.put("address", address);
                    //values.put("body", body);
                    //contentResolver.insert(Uri.parse("content://sms/inbox"), values);
                    this.abortBroadcast();
                    //create new pdu from the edited data
                    byte[] pdu = .......;
                    intent.putSerializableExtra("pdus", pdu);
                    context.sendBroadcast(intent);
            }
        }
    }
Sreejith Krishnan R
  • 1,244
  • 10
  • 12