Android中如何查询彩信日志

发布于 2024-08-16 17:14:10 字数 1016 浏览 5 评论 0原文

在我的应用程序中,我需要查询短信和彩信日志以获取所有传入和传出消息的历史记录。这段代码对于短信效果非常好:

Cursor c = cr.query(Uri.parse("content://sms"), null, null, null, null);

但是当我尝试以下操作时,我得到了完全不同的结果:

Cursor c = cr.query(Uri.parse("content://mms"), null, null, null, null);

短信查询返回的数据包括消息地址(电话号码)、联系人姓名、消息主题、消息正文等...相同MMS 查询返回一堆我无法理解的空值或数值字段。我确实需要手机上当前所有彩信的列表,以及与其关联的电话号码或联系人 ID,以及该消息是传入还是传出消息。在短信查询结果中,我可以从 address 字段获取电话号码,从 type 字段获取传入/传出类型,但当我查询彩信时,这些都不存在。

我是否需要查询此类 MMS 数据的不同内容 Uri?任何帮助将不胜感激。

编辑:只是为了澄清,我完全知道这是一个不受支持的内容提供商。然而,由于没有支持的方法来执行此操作,我完全愿意在每部手机/每个操作系统版本的基础上测试和支持这一点。为了让讨论顺利进行,假设这个问题特定于 HTC Dream (G1) 或 HTC Magic (MyTouch) 上的 Android 1.6。您将如何在特定的手机和操作系统版本上完成此任务?或者,如果在这些上不可能,但在摩托罗拉 Droid 上的 Android 2.0 上可以,那么我会发现该信息也非常有帮助。但无论如何,让我们继续讨论如何以受支持或不受支持的方式完成此任务,而不是让它演变成我们应该如何远离 API 不支持的事物的讨论,这是我所关心的。发现 Android 讨论组充满了问题,我觉得这些讨论组几乎没有提供任何帮助。如果我使用不受支持的方法,那也没关系,请向我展示完成该任务的受支持方法。如果没有支持的方法,那么为什么 API 支持允许我通过 android.permission.READ_SMS 请求读取短信的权限?

In my app I need to query both the SMS and the MMS log to get the history of all incoming and outgoing messages. This code has worked wonderfully for SMS:

Cursor c = cr.query(Uri.parse("content://sms"), null, null, null, null);

But when I try the following I get completely different results:

Cursor c = cr.query(Uri.parse("content://mms"), null, null, null, null);

The SMS query returns data that includes the message address (phone number), contact name, message subject, message body, etc... The same query for MMS returns a bunch of nulls or numeric value fields that I can't make any sense of. I really need a list of all MMS messages currently on the phone with the phone number or contact ID associated with it, and if the message was an incoming or outgoing message. In the SMS query results I can get the phone number from the address field, and the incoming/outgoing type from the type field but neither of these exist when I query for MMS.

Is there a different content Uri that I need to query for this sort of MMS data? Any help would be greatly appreciated.

Edit: Just to clarify, I'm completely aware that this is an unsupported content provider. However since there is no supported way of doing this I'm fully willing to test and support this on a per phone/per OS version basis. Just to keep the discussion on track lets say this question is specific to Android 1.6 on an HTC Dream (G1) or HTC Magic (MyTouch). How would you accomplish this task on that specific phone and OS version? Or if it's not possible on those, but it is possible on Android 2.0 on a Motorola Droid, then I would find that information very helpful as well. But regardless, lets stick to the discussion of how to accomplish this task in a supported or unsupported manner and not let it devolve into a discussion of how we should all stay away from things that aren't supported by the API, which is something I find the Android discussion groups to be riddled with and which I feel provides little to no help whatsoever. If I'm using an unsupported method, that's fine, show me the supported method of accomplishing that task. If there is no supported method, then why does the API support allowing me to request permission to read SMS via android.permission.READ_SMS?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情绪 2024-08-23 17:14:10

这些是我过去使用过的内容。您将不得不摆弄返回的值,并且距离获取彩信的各个部分还有很长的路要走,但希望它会有所帮助。

// root URI for MMS messages
static final String MMS_CONTENT_URI = "content://mms";

// root URI for MMS and SMS threads
public static final String MMS_SMS_CONTENT_URI = "content://mms-sms";

// URI of MMS inbox
public static final String RECEIVED_MMS_CONTENT_URI = MMS_CONTENT_URI + "/inbox";

// URI where sent MMSes are stored
public static final String SENT_MMS_CONTENT_URI = MMS_CONTENT_URI + "/sent";

// URI where sent MMSes are stored
public static final String MMS_PART_URI = MMS_CONTENT_URI + "/part";

// URI for incoming SMSes (also triggers on MMSes)
public static final String SMS_INBOX_URI = "content://sms/inbox";

These are the content uris I've used in the past. You'll have to fiddle with the values you get back, and it's a long way from getting the parts of an MMS, but hopefully it'll help.

// root URI for MMS messages
static final String MMS_CONTENT_URI = "content://mms";

// root URI for MMS and SMS threads
public static final String MMS_SMS_CONTENT_URI = "content://mms-sms";

// URI of MMS inbox
public static final String RECEIVED_MMS_CONTENT_URI = MMS_CONTENT_URI + "/inbox";

// URI where sent MMSes are stored
public static final String SENT_MMS_CONTENT_URI = MMS_CONTENT_URI + "/sent";

// URI where sent MMSes are stored
public static final String MMS_PART_URI = MMS_CONTENT_URI + "/part";

// URI for incoming SMSes (also triggers on MMSes)
public static final String SMS_INBOX_URI = "content://sms/inbox";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文