在Android问题上收到长短信

时间:2012-03-09 22:15:38

标签: android sms encryption

我的代码有问题。当我收到超过160个字符的短信时,该消息看起来有点加密。例如文字:

  

作者:Matt Brian,下一个网站可能是新款iPad的Retina Display   Apple新款平板电脑中最受期待的功能,   特别是在它结合了高分辨率显示器之后。

给出结果:

消息1:èsACiiAèeSCÑY¡(QKAÆKqiA.KÑA(QKAÖKoARaCIgAdKiSÑCAHSgaYCsAnCgA¿KeQCagAhQKAZ§giAJqaKGiKIALKCikeKAh§ADKARÑGYKIKIARÑABaaYKgAÖKoAhCEYKiY¡JgaKGSCYYsABMiKe

消息2:ÖG§ea§eCiKIAhQKAPSOQÄdKg§YkiS§ÑAHSgaY

代码段如下所示:

public void onReceive( Context context, Intent intent ){

    // Get the SMS map from Intent
    Bundle extras = intent.getExtras();

    if ( extras != null ){

        // Get received SMS array
        Object[] smsExtra = (Object[]) extras.get( "pdus" );

        for ( int i = 0; i < smsExtra.length; i++ ){

            SmsMessage sms = SmsMessage.createFromPdu((byte[])smsExtra[i]);

            String body = sms.getMessageBody().toString();
            String address = sms.getOriginatingAddress();

            try {

                sendMessageToServer(new Message(address, body));

            } catch (IOException e) {

                Log.w("Receive SMS", "Application not connected to server");
            }                
        }
    }

最后我会补充说,正确显示包含少于160个字符的短信。

0 个答案:

没有答案