Reputation: 28695
I send an sms via the SmsManager API as follows:
PendingIntent sentPI = PendingIntent.getBroadcast(context, 0, new Intent("SMS_SENT"), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, new Intent("SMS_DELIVERED"), 0);
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phone, null, formattedMessage, sentPI, deliveredPI);
I receive the SMS in the inbox, but the sent sms does not appear in the sent folder - so currently I add it manually via:
// store the sent sms in the sent folder (that shouldn't be necessary?!)
ContentValues values = new ContentValues();
values.put("address", phone);
values.put("body", formattedMessage);
context.getContentResolver().insert(Uri.parse("content://sms/sent"), values);
But I'm curious if this is really necessary and the right way to do it. I am wondering, why would the message sent via sms manager not appear in the SENT folder automatically. Is that the right way to add it there manually?
(I probably should hang the manual saving procedure into a broadcast receiver, so I only store it if the delivery was successful - but that's not part of the question at the moment).
I found this thread on the Android google group, but is this really the only way to go?
Upvotes: 4
Views: 3574