I am doing an app to send SMS from my computer through my android phone using a bluetooth connection. I use my android phone to send the SMS with the following code:
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNum, null, MessageText, null, null);
I don't care about the notification yet. However, when I send a SMS using the app, I would like to be able to see it when I come back in the basic messaging service of my phone. But it isn't the case here.
Have you got some ideas ?
Sending and SMS through SMSManager will never add the text to the other texting app, you have 2 options
1) The "correct" android way using intents (this will take users out of the app)
Intent sendSMS = new Intent(Intent.ACTION_VIEW);
sendSMS.setType("vnd.android-dir/mms-sms");
sendSMS.putExtra("address", "5558675309");
sendSMS.putExtra("sms_body","Your message here");
startActivity(sendSMS);
2) The undocumented way that seems to work most of the time here (Your mileage may vary).
// code shamelessly copied from link above
Context context; //you should initialize it somewhere
...
ContentValues values = new ContentValues();
values.put("address", number);
values.put("body", message );
values.put("date", time );
context.getContentResolver().insert(Uri.parse("content://sms/sent"), values);
You should be adding the entry into the content provider: Something like this on succesfuly sending the SMS:
ContentValues values = new ContentValues();
values.put("address", mPhoneNumber);
values.put("body",message);
getContentResolver().insert(Uri.parse("content://sms/sent"), values);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.