BroadcastReceiver for multipart SMS

后端 未结 2 649
傲寒
傲寒 2021-01-18 23:24

I need to store sms to a sqlite db when I receive one. At this moment it works fine with sms (160 chars), but if I receive a multipart sms it truncate the sms at about 155 c

2条回答
  •  醉梦人生
    2021-01-18 23:44

    according to several applications, it seems that multipart SMS are received in the same intent, and that they are represented by the messages array.

    so basically, you retrieve the complete message:

    StringBuffer content = new StringBuffer();
    for (Message sms : messages) {
        content.append(sms.getDisplayMessageBody());
    }
    String mySmsText = content.toString();
    

    As far as I know, it seems that the messages are in the correct order. Anyway, I don't know of any way to retrieve the message header (except parsing the pdu yourself).

提交回复
热议问题