使 Android Messaging 应用程序识别从其他应用程序发送的消息

发布于 2024-10-09 12:03:36 字数 154 浏览 1 评论 0原文

当我在 Android 应用程序中发送 SMS 消息时,是否可以使内置消息应用程序识别出该消息已发送并将其显示在适当的线程中?

目前,当我的应用程序发送消息时,没有发送消息的记录。我希望该消息像从手机发送的任何其他消息一样显示。我希望有比手动将消息添加到短信数据库更容易的事情。

When I send an SMS message in my Android application, is it possible to make the built-in Messaging app recognize that the message was sent and show it in the appropriate thread?

Currently when my app sends a message, there is no record of it being sent. I would like the message to show up like any other message sent from the phone. I'm hoping for something easier than manually adding the message to the sms database.

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

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

发布评论

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

评论(2

醉梦枕江山 2024-10-16 12:03:36

您可以使用以下代码将其存储到与消息应用程序相同的文件夹中。

        ContentValues values = new ContentValues();
        values.put("address", phoneNumber);
        values.put("body", smsText);
        // Note: This uses an Android internal API to save to Sent-folder
        context.getContentResolver().insert(Uri.parse("content://sms/sent"), values);   

这使用了一些内部 API,并且可能会在未来的版本中停止/在某些手机上不起作用,但正如我在评论中提到的,一些安装量达数百万的应用程序正在执行类似的操作。

You can use the following code to store to the same folder as Messaging app.

        ContentValues values = new ContentValues();
        values.put("address", phoneNumber);
        values.put("body", smsText);
        // Note: This uses an Android internal API to save to Sent-folder
        context.getContentResolver().insert(Uri.parse("content://sms/sent"), values);   

This uses some internal APIs and may brake in future releases / not work on some phones, but as I mentioned in my comment some apps with millions of installs are doing something similar.

苍暮颜 2024-10-16 12:03:36

是否可以使内置消息应用程序识别出消息已发送并将其显示在适当的线程中?

Android 中没有“内置消息应用程序”。虽然每台具有 SMS 功能的设备都有一个 SMS 客户端,但只有部分设备使用属于 Android 开源项目一部分的 Messaging 应用程序。其他人用自己的。

无论如何,他们只显示他们发送的消息。 “发送”消息和“适当的线程”的概念是客户端概念,而不是操作系统概念。

我希望有比手动将消息添加到短信数据库更简单的方法。

Android 中没有“短信数据库”。您可能会想到消息应用程序中的内容提供商。再次强调,消息应用是一个应用,而不是操作系统功能,并且该应用并不存在于所有设备上。消息应用程序的“短信数据库”没有记录或支持 - 相反,Google 明确声明不供您使用

is it possible to make the built-in Messaging app recognize that the message was sent and show it in the appropriate thread?

There is no "built-in Messaging app" in Android. While each device with SMS capability has an SMS client, only some use the Messaging app that is part of the Android open source project. Others use their own.

Regardless, they only show messages they sent. The notion of "sent" messages and "the appropriate thread" is a client concept, not an operating system concept.

I'm hoping for something easier than manually adding the message to the sms database.

There is no "sms database" in Android. You are probably thinking of the content provider from the Messaging app. Again, the Messaging app is an app, not an operating system feature, and that app is not on every device. The Messaging app's "sms database" is not documented or supported -- on the contrary, Google specifically states that it is not for your use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文