I’m coding an Android APK to manage GPS trackers by SMS. My software has a special notification part that decodes all alarms that device sends via SMS messages. Problem is that some phone companies use different limits for SMS length, so my code fails due to truncated messages. I’ve tested three different local companies and some of them use 140 chars while others use 70 chars. My question… is there any reliable way of getting that parameter? I’ve read all SDK docs and found nothing like that but the obvious constant MAX_USER_DATA_BYTES.
Share
As this is a very convoluted matter and requires piecing together different parts of standards and protocols, I’ve decided to post all the info I’ve found for whoever needs to solve this issue like me.
All checks should be done in PDU data directly, accessing bits and bytes, either within SmsMessage with
getPdu()or directly accessing thePDUarray from Bundle inonReceive()of your SMSBroadcastReceiver.First of all, we need to check two things for detecting a multi-part SMS:
IDH, bit 6 inPDU_TYPEIDH, second byte ofUDHinfoAfter detecting a multi-part message we need to identify messages belonging to same multi-part by checking CSMS identifier, number of parts and part index.