Hi, I am trying to send a multipart SMS using the following code. While the SMS is being split into multiple parts and sent across, in the receiver, I am seeing some junk characters (as if i am reading a binary file). Obviously, I am not doing something correct. Can someone (plusminus ) help?
// SMS SENDER package com.test; import java.util.ArrayList; import android.app.Activity; import android.app.PendingIntent; import android.content.Intent; import android.os.Bundle; import android.telephony.gsm.SmsManager; import android.util.Log; public class SMSSender extends Activity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); SmsManager smsManager = SmsManager.getDefault(); String destAddr = "5556", scAddr = null, mMessageText = "This is a sample SMS which has more than 160 characters if it has more characters, it will give an error as the standard SMS can contain only 160 characters. This text does not appear"; PendingIntent sentIntent = null, deliveryIntent = null; try { ArrayList<PendingIntent> listOfIntents = new ArrayList<PendingIntent> (0); //PendingIntent il = PendingIntent.getBroadcast(this, 0, new Intent(), 0); ArrayList<String> messages = smsManager.divideMessage(mMessageText); Log.v("****************", messages.toString()); for (int i=0; i < messages.size(); i++){ PendingIntent pi = PendingIntent.getBroadcast(this, 0, new Intent(), 0); listOfIntents.add(pi); } smsManager.sendMultipartTextMessage(destAddr, null, messages, listOfIntents, null); } catch (Exception e) { Log.i("TEST", e.toString()); } } } ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // SMS Receiver package com.test; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.gsm.SmsMessage; import android.util.Log; public class SMSReceiver extends BroadcastReceiver { private static final String TAG = "SMSReceiver"; static final String ACTION = "android.provider.Telephony.SMS_RECEIVED"; public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(ACTION)) { StringBuilder buf = new StringBuilder(); Bundle bundle = intent.getExtras(); if (bundle != null) { Object[] pdusObj = (Object[]) bundle.get("pdus"); SmsMessage[] messages = new SmsMessage[pdusObj.length]; for (int i = 0; i<pdusObj.length; i++) { messages[i] = SmsMessage.createFromPdu ((byte[]) pdusObj[i]); SmsMessage msg = messages[0]; Log.i(TAG, msg.getDisplayMessageBody()); }}}}} Thanks, Chethan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---