编程发送短信不会保存到已发送邮件 [英] Sending SMS programatically doesn't save it to Sent Items
本文介绍了编程发送短信不会保存到已发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编程方式从我的应用程序发送短信。在发送的邮件不会保存在发送邮件文件夹。我看了几个帖子,尤其是这一个...
I am sending an SMS programmatically from my app. The sent message is not saved in Sent Items folder. I have read few posts, especially this one...
的http://android-developers.blogspot.com/2010/05/be-careful-with-content-providers.html
不过,我必须将它保存在已发送邮件,因为我确实发送短信。什么是做这样的方式,我的应用程序不破的最佳方式?
But I do need to save it in Sent Items as I have indeed sent an SMS. What is the best way to do it such a way that my app doesn't break?
推荐答案
您可以保存信息务实,发信息或收件箱中。
You can save Message Pragmatically, in sent items or in inbox.
public boolean restoreSms(Sms obj) {
boolean ret = false;
try {
ContentValues values = new ContentValues();
values.put("address", obj.getAddress());
values.put("body", obj.getMsg());
values.put("read", obj.getReadState());
values.put("date", obj.getTime());
mActivity.getContentResolver().insert(
Uri.parse("content://sms/sent", values);
//Uri.parse("content://sms/inbox", values);
ret = true;
} catch (Exception ex) {
ret = false;
}
return ret;
}
在AndroidManifest使用此权限
Use this permission in AndroidManifest
<uses-permission android:name="android.permission.WRITE_SMS" />
这篇关于编程发送短信不会保存到已发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文