3

I want to hide my sent items when i send any sms from my app or dont log it at all.

Here is the code i have here:

SmsManager smsManager = SmsManager.getDefault();
PendingIntent piSent = PendingIntent.getBroadcast(contextUpdate, 0, new Intent("SMS_SENT"), 0);
PendingIntent piDelivered = PendingIntent.getBroadcast(contextUpdate, 0, new Intent("SMS_DELIVERED"), 0);
smsManager.sendTextMessage(alarmNumber, null, alarmCode + " " + sentDisarmCode + " OFF", piSent, piDelivered);

If am not mistaken to skip saving the sms in sent i have to write null to piSent and piDelivered. But i need these 2 broadcasts so i know if my messaged is sent by a toast message i have and to know if its delivered.

Is there anything else i should try?

1 Answers1

0

It appears you're dealing with KitKat or above, as prior to that, any app sending SMS using SmsManager would need to explicitly write the messages to the Provider for them to appear in any other app. That being the case, your app will need to be the default SMS app in order to "hide" the sent messages. Starting with KitKat, any app that is not the default and uses the methods of SmsManager to send messages has those messages automatically written to the Provider by the system. The PendingIntents are used only for Sent and Delivered confirmation, and have nothing to do with the writing of the messages.

The default SMS app, on the other hand, is responsible for writing all of its own outgoing messages itself. No automatic writes are done for it, and it can choose to omit them. You can consult the following link for information on how to make your app eligible to be a default SMS app.

Getting Your SMS Apps Ready for KitKat

Mike M.
  • 38,532
  • 8
  • 99
  • 95