How can I send 140 byte in one SMS by sendDataMessage()

我只是一个虾纸丫 提交于 2020-01-06 10:54:22

问题


I have read on different forums that we can send 160 (7 bit) characters and 140 (8 bit) bytes in one SMS message.

I want to send 140 bytes of data in one SMS. I am can successfully send up to 133 bytes but not more than 133 bytes, Can any one guide Why I am unable to send 140 bytes of 8 bit data in one SMS through smsManager.sendDataMessage

Below is my code.

      int MAX_SMS_MESSAGE_LENGTH = 140;
      byte[] bArray = new byte [MAX_SMS_MESSAGE_LENGTH];
      for(int i=0;i<MAX_SMS_MESSAGE_LENGTH;i++)
      {
           bArray[i] = (byte)i;
      }
      PendingIntent sent = this.createPendingResult(SENT, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
      String messageText = _message.getText().toString();

     SmsManager smsManager = SmsManager.getDefault();
     smsManager.sendDataMessage(_phoneNumber.getText().toString(), null, SMS_PORT, bArray, sent, null);

Thanking in an Anticipation,

Regards,

AK


回答1:


Part of the 140 bytes is reserved for the User Data Header (UDH) which is usually 7 bytes in size. More info can be found here.



来源:https://stackoverflow.com/questions/23180842/how-can-i-send-140-byte-in-one-sms-by-senddatamessage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!