Hello,

As mentioned in an earlier post I am trying to send binary SMS
from one phone to another. I use the emulator number as the
phone number destination address in order to test things out.

When the SMS is not binary (sendTextMessage below) things
work fine, the message is received by the other emulator and
I see the string output. However when I use sendDataMessage
(presumably this is to send a binary SMS), the sending emulator
stalls (I see the small windows spinning blue circle) for a while
(a few seconds) after which I do not see the Log.d output in the
receiving emulator.

I would like to know what I am doing wrong. Also, how do I:

1. Specify class 0 for the SMS if this in not done automatically?
2. Listen on the specified port number (123) on the receiver?
3. Choose an appropriate SMS port number for my application?
4. Can someone please explain to me what the getSubmitPdu
    method is good for? I've read the docs and also the reference
    on SMS at http://www.dreamfabric.com/sms/ and the android
    docs but I still cannot figure it out.
5. Am I correct at interpreting that with sendDataMessage an
    SMS status report will be generated if and only if the last
    argument (the pending intent) is not null, otherwise the
    SMS will be sent without specifying that a status report
    be generated?

Thank you for your help,

John Goche

FooActivity.java ------------------------------------------------------------

        SmsManager smsManager = SmsManager.getDefault();

        //smsManager.sendTextMessage("5556", null, "hello SMS", null, null);

        smsManager.sendDataMessage("5556", null, (short) 123, new
byte[] { '1', '2', '3', '4' }, null, null);


SMSReceiver.java ---------------------------------------------------------

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.SmsMessage;
import android.util.Log;

public class SMSReceiver extends BroadcastReceiver {

  @Override
  public void onReceive(Context context, Intent intent) {

    Object[] pduArray = (Object[]) intent.getExtras().get("pdus");

    SmsMessage[] messages = new SmsMessage[pduArray.length];

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

      Log.d(TAG, "received");

      messages[i] = SmsMessage.createFromPdu((byte[]) pduArray[i]);

      Log.d(TAG, messages[i].getDisplayOriginatingAddress());

      Log.d(TAG, messages[i].getMessageBody());

    }

  }

  private static final String TAG = "SMSReceiver";

}

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

Reply via email to