Caleb Bramwell
Caleb Bramwell

Reputation: 1342

Programmatically Send SMS without it showing in Messaging App

Is there a way to programmatically send sms messages without them showing in the Messaging app? I am using the following code to send SMS:

    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage("number", null, "message", null, null);

And the messages are showing in the default Messaging app aswell as Google Hangouts. For my application it would be ideal for the messages not to show up, as they are simply sending code to a GSM module, and they just fill up the users Messaging app.

Upvotes: 1

Views: 1467

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93561

If you aren't sending real texts, you should probably send a port based SMS which won't be added to the messaging DB. But if you can't, you need to delete it from the sms content resolver.

ctx.getContentResolver().delete(Uri.parse("content://sms/inbox"), {"body"}, messageBodyToDelete);

Upvotes: 1

Related Questions