Search code examples
androidsmsmanager

Android - Sent SMS message does not show in native Messages app


We have an app that detects and receives incoming SMS messages, and then auto-responds to those messages. All of this is working great.. however there is one quirk we have noticed. On my Android phone (LG L70), it works fine to show the auto-response in the native "Messages" app. However, on a different device that we are using for testing (S4 mini), the auto response does not show. But the auto-response message actually is sent with no issues from the device.

Here is the code that sends the SMS message:

SmsManager.getDefault().sendTextMessage(message.getSenderNumber(),
            null,
            autoResponseText,
            PendingIntent.getBroadcast(this, 0, new Intent(ACTION_SMS_SENT), 0),
            null);

This has us scratching our heads, needless to say. These are new "test" phones that we bought, so they are not bogged down by other installed apps that would seemingly interfere with this kind of thing. We have tried changing all kinds of settings and even uninstalling things like Google Hangouts, etc. But no luck. For some reason, it works fine on my phone to show all the messages in the native "Messages" app, but on the other phone, it does not.

Could this be a device-specific issue? Or is it something we can address in the code? If more info or code is needed on this, I'd be glad to provide it. Thanks in advance!


Solution

  • Turns out this post had the correct answer, and the comment from Rhth was indeed correct.

    However, it's important to note that the code to use the ContentResolver to query and find the message did not work properly, I'm guessing because the SmsManager sends the message asynchronously and doesn't insert into the ContentResolver until completed.. so it was unable to find it yet when the code to search is called right after the SmsManager sending of the message.

    I imagine with a delay of some sort, I could get in a state in which it works, but oddly enough, I didn't have to worry about it, since the code to manually insert the message via the ContentResolver works fine across both of the previously-mentioned devices! I.e. it does not duplicate the message on the device that works properly. So it kind of worked out for the best across all fronts.