为什么无法读取来自“Android设备”的消息?使用GSMComm库,c#

本文关键字:消息 使用 GSMComm 设备 读取 Android 为什么 | 更新日期: 2023-09-27 17:50:16

我正在使用GSMComm库发送和接收消息(桌面应用程序)…发送代码工作完美…问题是当收到消息时,我是无法读取消息,而使用Android设备,替换了至少4个三星设备,然而它是与GSM-3G设备完美配合

错误显示在下一行DecodedShortMessage message = messages[indexx];返回错误消息"索引超出数组的边界"。/

Android 不允许从手机内存中读取消息,同时允许发送消息?

我已经尽力了,但还是控制不了自己。

 private void comm_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            try
            {
                IMessageIndicationObject obj = e.IndicationObject;
                if (obj is MemoryLocation)
                {   
                    MemoryLocation loc = (MemoryLocation)obj;
                    string storage=loc.Storage;
                    int indexx = loc.Index;
                    DecodedShortMessage[] messages = comm.ReadMessages(PhoneMessageStatus.All, loc.Storage);
           //Error Shows up in next Line ,
           //Exception Message is "Index was outside the bounds of the array."
                    DecodedShortMessage message = messages[indexx];
                    SmsPdu pdu = message.Data;
                    if (pdu is SmsDeliverPdu)
                    {
                        SmsDeliverPdu data = (SmsDeliverPdu)pdu;
                        MessageBox.Show(data.OriginatingAddress.ToString() + data.UserDataText.ToString());
                    }
                    return;
                }
                MessageBox.Show("Error: Unknown notification object!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message + " (" + ex.GetType().ToString() + ")");
            }
        }

已尝试的引用

    官方网站
  1. 代码项目黑名单短信发件人
  2. 发送接收短信

为什么无法读取来自“Android设备”的消息?使用GSMComm库,c#

是的,因为我从论坛上读到android不允许用gsmcomm从手机内存中读取消息,你可以使用android客户端通过插座从android发送短信到pc,或者如果你有很多钱,你可以使用android,我看到一篇关于如何接收和发送短信的文章。

我有一个关于如何从SmsDeliverPdu对象获得发送方和接收方号码的问题,因为我需要发送方和接收方来验证短信或如何获得手机的sim号码