Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:50:53+00:00 2026-06-17T08:50:53+00:00

I’m coding an Android APK to manage GPS trackers by SMS. My software has

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:50:54+00:00Added an answer on June 17, 2026 at 8:50 am

    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 the PDU array from Bundle in onReceive() of your SMS BroadcastReceiver.

    First of all, we need to check two things for detecting a multi-part SMS:

    1. Presence of IDH, bit 6 in PDU_TYPE
    2. Presence of multipart indicator in IDH, second byte of UDH info

    After 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.

    /**
     * EXAMPLE OF A PDU 
     *
     * 07 length of SMSC info in bytes
     * 91 type of address
     * 551218317600 SMSC address (variable size)
     * 04 PDU_TYPE to check for IDH embedded test bit 6  0=not UDH  1=has UDH
     * 0B address length in nibbles, here is 11 nibbles so its 6 bytes
     * 81 address type
     * 1089920478F1 sender number (variable size)
     * 00 TP-PID
     * 08 TP-DCS
     * 31105161225188  TP-SCTS  timestamp
     * 38  TP-UDL user data length
     * [USER DATA STARTS HERE] When UDH info is embedded, starts in first
     *                         bytes of user data
     * 
     * EXAMPLE OF UDH for 8 bit CSMS reference (unique number, indicates
     * parts belong to same message)
     *
     * 05 UDH length in bytes
     * 00 For multipart 8 bits CSMS it is 00, for 16bits CSMS it is 08
     * 03 length of header
     * 48 CSMS reference number, this identify SMSs that belong
     *                           to same multi-part
     * 02 total parts of this sequence (in this case, 2 parts)
     * 02 sequence number (in this case, 2 of 2)
     *
     *
     * EXAMPLE OF UDH for 16 bit CSMS reference (unique number, indicates
     * parts belong to same message)
     *
     * 06 UDH length in bytes
     * 00 For multipart 8 bits CSMS it is 00, for 16bits CSMS it is 08
     * 04 length of header
     * 4823 16 bits CSMS reference number, this identify SMSs that belong
     *                                     to the same multi-part
     * 02 total parts of this sequence (in this case, 2 parts)
     * 01 sequence number (in this case, 1 of 2)
     * 
     */
    
    // SOME HELPERS TO CHECK FOR MULTIPART INSIDE PDU
    
    private final byte UDH_BITMASK = 0x60;
    private final byte MULTIPART_8BITSEQ = 0x00;
    private final byte MULTIPART_16BITSEQ = 0x08;
    
    private final int TP_ADDLENGTH_LEN=1;
    private final int TP_ADDTYPE_LEN=1;
    private final int TP_PID_LEN=1;
    private final int TP_DCS_LEN=1;
    private final int TP_SCTS_LEN=7;
    private final int TP_UDL_LEN=1;
    
    /**
     * Check if this PDU message is multi part
     * @param pdu
     * @return
     */
    private boolean isMultiPart(byte[] pdu)
    {
        // get length of first part+1 SMSC index to PDU type
        int idx= pdu[0]+TP_ADDLENGTH_LEN;
    
        if((pdu[idx] & UDH_BITMASK) != 0) // has UDH ??
        {
            // 00=length of UDH  01=type
            int udataidx = getUserDataIndex(pdu);
            if( (pdu[udataidx+1] == MULTIPART_8BITSEQ)
             || (pdu[udataidx+1] == MULTIPART_16BITSEQ))
                return true;
        }
    
        return false;
    }
    
    
    /**
     * Return index for user data part. Used to retrieve UDH info
     * @param pdu
     * @return
     */
    private int getUserDataIndex(byte[] pdu)
    {
        // get index to  ADDRESS length
        int idx=pdu[0]+ TP_ADDLENGTH_LEN + TP_ADDTYPE_LEN;
    
        // get length in nibbles
        int oalength = pdu[idx];
    
        // convert to bytes with padding for odd values
        int oalengthinbytes = (oalength + 1) / 2;
        return(idx + TP_ADDLENGTH_LEN + TP_ADDTYPE_LEN + oalengthinbytes +
                TP_PID_LEN + TP_DCS_LEN +  TP_SCTS_LEN + TP_UDL_LEN);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.