如何保存短信到收件箱中的android? [英] How to save SMS to inbox in android?

查看:149
本文介绍了如何保存短信到收件箱中的android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了下面的$ C $下发送短信。

I have written the below code for sending SMS messages.

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(destAddr, null, mMessageText, il, null);

但是,这没有更新我的收件箱中,我需要保存相同的邮件收件箱中, 或者是有没有办法来调用本机短信应用程序发送短信?

But this is not updating in my Inbox, I need to save the same message in Inbox, Or is there any way to invoke a native SMS application to send SMS ?

推荐答案

您可以使用手机短信内容提供商读写短信:

You can use the sms content provider to read and write sms messages:

ContentValues values = new ContentValues();
values.put("address", "123456789");
values.put("body", "foo bar");
getContentResolver().insert(Uri.parse("content://sms/sent"), values);

我不知道你为什么会想给你写的消息发送的到的收件箱的,但如果这是你想要的上述URI只是改变为内容://短信/收件箱

I don't know why you would want to write a message you send to the inbox but if that is what you want just change the above uri to "content://sms/inbox".

另外,您可以交给消息传递应用程序通过启动一个活动,意图类似以下内容:

Alternatively you can hand over to a messaging application by starting an activity with an intent similar to the following:

Intent sendIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("sms://"));
sendIntent.putExtra("address", "123456789");
sendIntent.putExtra("sms_body", "foo bar");
startActivity(sendIntent);

编辑:然而,短信:// 内容提供商是不是SDK的一部分,所以我强烈推荐的不是使用code这样的公共应用几个原因

However, the sms:// content provider is not part of the SDK so I strongly recommend not using code like this in public applications for several reasons.

这篇关于如何保存短信到收件箱中的android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆