0

I want to block incoming sms using my app. But, when user disable the blocking, I want all the previously blocked messages to go back to Inbox. I am aborting the sms using abortBroadcast() in smsBroadcastReceiver. How to resend these messages to inbox later? Do I have do something like saving the broadcasts and resend them later?

berserk
  • 2,690
  • 3
  • 32
  • 63
  • Do you just not want the incoming SMS notification to appear, or do you want to keep the messages unavailable (i.e., out of the inbox) until the user unblocks them? – Mike M. Sep 01 '14 at 07:41
  • @MikeM. Exactly the 2nd one! – berserk Sep 01 '14 at 07:43

1 Answers1

1

Store all incoming sms in your own database. After the user is unblocked you can recover the sms as Josef Pfleger wrote in one of his answers:

You can use the sms content provider to read and write sms messages:

ContentValues values = new ContentValues();
values.put("address", "123456789");
values.put("body", "foo bar");
getContentResolver().insert(Uri.parse("content://sms/inbox"), values);

However, the sms:// content provider is not part of the SDK so I strongly recommend not using code like this in public applications for several reasons.

It seems to be the most populare way however it is not official.

Community
  • 1
  • 1
rekire
  • 47,260
  • 30
  • 167
  • 264