Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Multi-Part sms content becomes unreadable on reception
    text
    copied!<p>I am working on an android project, that deals with device authentication via sms. The problem I am facing is, when the authentication key is being sent, the receiving device gets a garbled text and not the original sent content.</p> <p>I am using two instances of the emulator to test the code.</p> <p>Here is the relevant code :</p> <pre><code>String MyPublic = "__key("+N.toString()+")yek__"; ArrayList&lt;String&gt; parts = smsmgr.divideMessage(MyPublic); smsmgr.sendMultipartTextMessage(senderNumber, null, parts, null, null); </code></pre> <p>How ever when I am sending a single sms within 160 characters, then this problem isn't disappears.</p> <p>Here is the code I am using to listen for incoming messages.</p> <pre><code> public void onReceive(final Context context, Intent intent) { msgReceived = false; Object[] pdus=(Object[])intent.getExtras().get("pdus"); Bundle bundle = intent.getExtras(); if (bundle != null) { pdus = (Object[])bundle.get("pdus"); final SmsMessage[] messages = new SmsMessage[pdus.length]; for (int i = 0; i &lt; pdus.length; i++) { messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]); } SmsMessage sms = messages[0]; String body; if (messages.length == 1 || sms.isReplace()) { body = sms.getDisplayMessageBody(); } else { StringBuilder bodyText = new StringBuilder(); for (int i = 0; i &lt; messages.length; i++) { bodyText.append(messages[i].getMessageBody()); } body = bodyText.toString(); } } </code></pre> <p>The message that is received when the 'Multi-part' thing is used is of this type : <img src="https://i.stack.imgur.com/dpNx6.png" alt="enter image description here"></p> <p>The "HelloWorld" was sent as a single-part message(Non-Multipart) and the 3rd and second from below are parts of that multipart authentication key.</p> <p>Need Help resolving this.</p> <p>Regards Priyabrata.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload