1

I using "sendTextMessage" in android SDK to send message programmatically. But the sent message doesn't show up in the outbox.

public void sendSMS() {
    String phoneNumber = "0123456789";
    String message = "Hello World!";

    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(phoneNumber, null, message, null, null);
}

Is there any other flag for adding the message to the outbox?

ssk
  • 9,045
  • 26
  • 96
  • 169

1 Answers1

4

The concept of "outbox" depends on the SMS application. You cannot programatically add SMS's to outboxes of SMS applications on the device (there could be more than one). If you want the SMS to be shown in the users default SMS application then use the intent ACTION_SEND to send the SMS

Code for doing it with an intent

Uri uri = Uri.parse("smsto:xxxxxxx");   
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);   
it.putExtra("sms_body", "THE SMS BODY");   
startActivity(intent); 

In short, If you want to send it programatically using SMSManager It would not show in the outbox. Use intents for that.

Ahmed Aeon Axan
  • 2,139
  • 1
  • 17
  • 30
  • 1
    I used android.telephony.SmsManager.sendTextMessage, and messages were appearing in the outbox(in a Samsung Galaxy something, and an HTC phone, don't remember the exact model). According to your answer they modified the android OS in such a way that it stores every message sent and provide the sent messages to the apps which require it? –  Mar 10 '13 at 19:53