开发者

Sending SMS programatically doesn't save it to Sent Items

I am sending an SMS 开发者_C百科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;
}

Use this permission in AndroidManifest

<uses-permission android:name="android.permission.WRITE_SMS" />


Use the builtin sms app for sending the sms, have a look at this post with a code snippet how to do this: launch sms application with an intent

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜