Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Send SMS and make it show up in the SMS inbox?

I finally got my app to be able to send text messages (SMS), but the problem now is that i need the messages to show up in the inbox if the user opens the sms app.

Is there any way to add text messages to the inbox?

I'm currently using the following code, could i alter it somehow to make it show up in the inbox?

private void sendSMS(String phoneNumber, String message)
{
    PendingIntent pi = PendingIntent.getActivity(ccc, 0, new Intent(), 0);
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, pi, null);
} 
like image 320
qwerty Avatar asked May 17 '12 18:05

qwerty


1 Answers

This link has an example of how to do it.

This function in the code does it, the complete example uses a service to accomplish the task:

private void addMessageToSent(String telNumber, String messageBody) {
    ContentValues sentSms = new ContentValues();
    sentSms.put(TELEPHON_NUMBER_FIELD_NAME, telNumber);
    sentSms.put(MESSAGE_BODY_FIELD_NAME, messageBody);

    ContentResolver contentResolver = getContentResolver();
    contentResolver.insert(SENT_MSGS_CONTET_PROVIDER, sentSms);
}

Hope this helps!

like image 68
SpeedBirdNine Avatar answered Sep 27 '22 17:09

SpeedBirdNine