2

I need to send sms message to the inbox but in same time I want to send a broadcast that other apps can receive it

Now I'm sending sms to inbox successfully using answer in this question but with no broadcast or alerts or any kind of notifications.

This is the code I'm using:

   fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ContentValues values = new ContentValues();
            values.put("address", "+123456789");//sender name
            values.put("body", "Welcome Home!");
            getContentResolver().insert(Uri.parse("content://sms/inbox"), values);
        }
    });

What I need to know is how to send this SMS in a broadcast that other apps can receive and makes android give alerts and notifications exactly like when it receives real SMS messages.

Unfortunately all questions here about sending such type of broadcasts are not answered or have no correct answer.

The application which will handle my SMS is using broadcast receiver for SMS not intent filter, it doesn't have any intent filter for SMS.

Edit

I need to send sms message to the inbox of the device where my app is not to other device's inbox.

Community
  • 1
  • 1
Mohammad
  • 1,185
  • 1
  • 14
  • 26
  • 1
    I don't know what you mean by your last paragraph, but you could use `SmsManager` to send yourself a text, and just let your regular SMS app take care of the write and broadcast. That's about the only way to do it reliably, since the `BROADCAST_SMS` permission is signature-level. – Mike M. Nov 13 '15 at 21:40
  • @MikeM. Thank you I'll study your suggestion and tell you if it worked. – Mohammad Nov 13 '15 at 21:45
  • No problem. Just to clarify, I misspoke slightly in my last comment. The SMS app will take care of the write; the system handles the broadcast, hence the signature-level permission. – Mike M. Nov 13 '15 at 21:49
  • I edited my question, can I use `SmsManager` to send sms internally? I mean not to another phone number or device. thanks :) – Mohammad Nov 13 '15 at 21:56
  • "can I use SmsManager to send sms internally?" - No. And by "send yourself a text", I meant send it to the device's own number, not another device. – Mike M. Nov 13 '15 at 22:30

0 Answers0