Home » Android » Block sent SMS from being logged in default messaging app

Block sent SMS from being logged in default messaging app

Posted by: admin November 1, 2017 Leave a comment


I have an auto reply sms Android application I built and I don’t want the auto reply (sent sms) to show in the default messaging app. I have searched and searched and couldn’t find an answer. Is there a way to bypass writing the sent sms into the default messaging app?

Here my BroadcastReciever I am using to get the data and send out the message

public class SmsReceiver extends BroadcastReceiver {

ParseUser user = ParseUser.getCurrentUser();
// Auto reply message composed of the current reply and url from that business
String msg = user.getString("myCurrentReply") + " " + user.getString("couponUrlChosen");

List smsFromList = user.getList("smsFrom");
String userName = (String) user.get("username");

public void onReceive(final Context context, Intent intent) {
    Bundle bundle = intent.getExtras();

    Object messages[] = (Object[]) bundle.get("pdus");
    SmsMessage smsMessage[] = new SmsMessage[messages.length];
    for (int n = 0; n < messages.length; n++) {
        smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
    final String pno = smsMessage[0].getOriginatingAddress();
    user.put("lastSmsFrom", pno);

    // show first message
    Toast toast = Toast.makeText(context, "Received SMS: " + smsMessage[0].getMessageBody(), Toast.LENGTH_LONG);

    // Check Phone Number from SMS Received against Array in User Row
    ParseQuery<ParseObject> query = ParseQuery.getQuery("_User");

    Log.d("Username: ", userName);
    query.whereEqualTo("username", userName);
    query.whereContainedIn("lastSmsFrom", smsFromList);
    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> smsList, ParseException e) {
            if (e == null) {
                Log.d("Errors", "none");
                if (smsList.size() == 0) {
                    // Send SMS
                    sendSms(pno, msg);

                    // Add Phone number to smsFrom in currentUsers Row
                    user.addUnique("smsFrom", pno);

                    // Save Phone Number in Array

                    Log.d("List size: ", " " + smsList.size());

            } else {
                Log.d("Error Message: ",
            Log.d("Already sent to this number today. ", " " + smsList.size());


private void sendSms(String phonenumber, String message) {

    SmsManager manager = SmsManager.getDefault();
    manager.sendTextMessage(phonenumber, null, message, null, null);


Prior to KitKat, SMS sent using SmsManager require the app sending the message to insert it into the Provider, so it would just be a matter of omitting that.

Starting with KitKat, any app that is not the default SMS app and uses SmsManager to send messages will have the messages automatically written to the Provider for it by the system. There’s no way to prevent this, and, furthermore, the app won’t be able to delete those messages, either, as it won’t have write access to the Provider.*

The app that is the default SMS app is responsible for writing its outgoing messages, so it would be able to omit that step. The system does no automatic writes for the default SMS app.

* There is a security hole in 4.4 only, by which a non-default app can gain write access to the Provider. It is detailed in my answer here, but it will not work in versions after KitKat.