Android 多部分短信 - 单独接收

发布于 2024-12-02 08:27:05 字数 394 浏览 5 评论 0原文

我正在开发一个短信网关应用程序,它从客户端应用程序接收短信,对其执行一些操作并将数据上传到服务器。

在客户端应用程序中,当消息长度超过 160 个字符时,我会在使用 divideMessage 方法拆分消息后执行 sendMultipartTextMessage 。然而,当 SMS 网关设备接收到消息时,BroadcastReceiveronReceive 每次调用仅获取一个 PDU 以及消息的不同部分。收到的相同短信是不同的短信。

是否有一些设置可以接收多部分短信?我使用华为 u8150 Helios 设备作为网关。我已经对设备进行了 root 操作,如果需要,我可以更改系统设置。

提前致谢。

I am developing an SMS gateway application which receives the sms'es from the client app, performs some operation on it and uploads the data to the server.

From the client app, when the message length grows beyond 160 Characters, I do a sendMultipartTextMessage after splitting the message using the divideMessage method. However, when the message is received in the SMS gateway device, the onReceive of the BroadcastReceiver gets only one PDU per call and different parts of the same sms is being received as different sms.

Is there some setting to enable receiving multipart sms'es? I'm using Huawei u8150 Helios device for the gateway. I have rooted the device and if needed I can change the system settings.

Thanks in advance.

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

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

发布评论

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

评论(1

黑寡妇 2024-12-09 08:27:05

对于那些正在寻找我如何解决此问题的人,这就是我所做的:

Sender:

  • 我没有使用内置的 divideMessage,而是创建了自己的 divideMessage 返回一个 ArrayList,其中每个元素都有一个前缀,其长度 <= 150(经验发现的数字)。
  • 使用内置的 sendMultipartTextMessage 发送上面获得的 ArrayList 消息。

接收者

  • 获取消息的前缀并将消息存储在本地数据库中。
  • 从前缀查看其所有其他部分是否已到达。如果是,则将所有部分合并并处理。

注意:前缀包含什么以及如何合并所有部分不属于本次讨论的范围。

For those of you who are looking for how I solved this problem, this is what I did :

Sender:

  • Instead of using the built in divideMessage, I created my own divideMessage which returns an ArrayList<String>, in which each element will have a prefix and whose length is <= 150 (Empirically found number).
  • send the above obtained ArrayList<String> of Messages using the built in sendMultipartTextMessage.

Receiver:

  • Get the prefix of the message and store the message in a local db.
  • From the prefix see if its all other parts have arrived. If yes, merge all the parts and process it.

Note: whats contained in prefix and how all parts are merged is not in the purview of this discussion.

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