开发者

sendMultipartTextMessage sends garbled messages

I'm writing an Android application that allows a call and response between two devices. I'm currently using sendMultipartTextMessage to send a message longer than 160 characters. However the message received is not the message I sent.

    String response = "abcd abcd abcd abcdabcd abcd abcd abcd abcd...to 300 chars";
    Log.i("response",response);

    SmsManager sms = SmsManager.getDefault();
    ArrayList<String> parts = sms.divideMessage(response);

    for (String part : parts) {
        Log.i("part",part);
 开发者_运维问答   }

    sms.sendTextMessage(sender, null, "This should be normal", null, null);


    sms.sendMultipartTextMessage(sender, null, parts, null, null);

The Log.i runs as expected and outputs the message in parts. The sendTextMessage also sends the correct SMS to my partner emulator. However, the parts sent by sendMultipartTextMessage all come back oddly translated. For example the above response would be received as "BEGIABEGIABEGIABEGIA..." and so on with a few minor variations for spaces and numbers.

What is causing sendMultipartTextMessage to garble the SMS?


Its a bug in the platform: see http://code.google.com/p/android/issues/detail?id=13737. It might be limited to the simulator, so try it on a real device.


sendMultipartTextMessage method does not work correctly when you run your android application from any simulator.
so you need to test your android application on actual android smart phone. one more thing to consider is always pass null as third second argument (string containing phone number of sender) while sending SMS otherwise code will not sms.

i hope this will help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜