0
我使用GSMComm Library發送和接收消息(桌面應用程序)... 發送代碼工作Perfectally .. 問題是,當一個消息收到了,我時無法使用Android設備閱讀的消息,更換一次,至少4級三星的設備,但是這是與GSM-3G設備爲什麼無法讀取信息從「Android設備」使用GSMComm庫,C#
錯誤顯示出來的,錯誤之後 線DecodedShortMessage message = messages[indexx];
工作完美消息「Ind ex超出了陣列的界限。「/
是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() + ")");
}
}
參考已經嘗試過
SmsDeliverPdu數據的SIM卡號碼的問題= (SmsDeliverPdu)PDU; MessageBox.Show(data.OriginatingAddress.ToString()); –
感謝您的回覆,但它只是發送短信的發件人號碼,但收到短信的SIM的號碼我不知道我是否錯了,但我們應該從comm.GetSubscriberNumbers()中獲取它;而且這個功能對我的模擬器不起作用,因爲網絡供應商不支持 –