I could not find the answer to this question. Why is the length of program data sent from one instance of the emulator to another truncated on the receiving side?
Here I am sending 20 bytes from emulator-554 to emulator-556, but emulator-556 accepts only 12 bytes:
emulator-554: SMS sender
private void sendSMS()
{
final int udLength = 20;
Log.d("SMS TEST", "SMSActivity.sendSMS ud.length=" + udLength);
byte[] payload = new byte[udLength];
for (byte i = 0; i < udLength; i++)
{
Log.d("SMS TEST", "payload[" + i + "]=" + i);
payload[i] = i;
}
Intent smsSentIntent = new Intent("SMS_SENT");
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, smsSentIntent, 0);
String destTelephone = "15555215556";
SmsManager smsMgr = SmsManager.getDefault();
smsMgr.sendDataMessage(destTelephone, null, (short) 32766, payload, sentPI, null);
Log.d("SMS TEST", "SMSActivity.sendSMS COMPLETED!");
}
Enter the sender emulator:
02-25 19: 31: 00.793: D/SMS TEST (257): onCreate
02-25 19: 31: 00.793: D/SMS TEST (257): onResume
02-25 19: 31: 00.823: D/SMS TEST (257): SMSActivity.sendSMS ud.length = 20
02-25 19: 31: 00.823: D/SMS TEST (257): [0] = 0
02-25 19: 31: 00.823: D/SMS TEST (257): [1] = 1
02-25 19: 31: 00.823: D/SMS TEST (257): [2] = 2
02-25 19: 31: 00.823: D/SMS TEST (257): [3] = 3
02-25 19: 31: 00.823: D/SMS TEST (257): [4] = 4
02-25 19: 31: 00.823: D/SMS TEST (257): [5] = 5
02-25 19: 31: 00.823: D/SMS TEST (257): [6] = 6
02-25 19: 31: 00.823: D/SMS TEST (257): [7] = 7
02-25 19: 31: 00.833: D/SMS TEST (257): [8] = 8
02-25 19: 31: 00.833: D/SMS TEST (257): [9] = 9
02-25 19: 31: 00.833: D/SMS TEST (257): [10] = 10
02-25 19: 31: 00.833: D/SMS TEST (257): [11] = 11
02-25 19: 31: 00.833: D/SMS TEST (257): [12] = 12
02-25 19: 31: 00.833: D/SMS TEST (257): [13] = 13
02-25 19: 31: 00.833: D/SMS TEST (257): [14] = 14
02-25 19: 31: 00.833: D/SMS TEST (257): [15] = 15
02-25 19: 31: 00.833: D/SMS TEST (257): [16] = 16
02-25 19: 31: 00.833: D/SMS TEST (257): [17] = 17
02-25 19: 31: 00.853: D / SMS TEST (257): payload [18] = 18
02-25 19: 31: 00.853: D / SMS TEST (257): payload [19] = 19
02- 25 19: 31: 00.904: D / SMS TEST (257): SMSActivity.sendSMS COMPLETED!
02-25 19: 31: 27.044: D / SMS TEST (257): onPause
02-25 19: 31: 27.583: D / SMS TEST (257): onStop
emulator-556: SMS receiverpublic class SmsReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED"))
{
Bundle bundle = intent.getExtras();
Object[] pdus = (Object[]) bundle.get("pdus");
Log.d("SMS TEST", "SmsReceiver.onReceive: pdus.length=" + pdus.length);
SmsMessage inboundSMS = SmsMessage.createFromPdu((byte[]) pdus[0]);
byte[] ud = inboundSMS.getUserData();
int udLength = ud.length;
Log.d("SMS TEST", "SmsReceiver.onReceive: ud.length=" + udLength);
for (int i = 0; i < udLength; i++)
{
Log.d("SMS TEST", "ud[" + i + "]=" + ud[i]);
}
Log.d("SMS TEST", "SmsReceiver.onReceive COMPLETED!");
}
}
}
Log in to the host emulator:
02-25 19: 31: 01.593: D/SMS TEST (258): SmsReceiver.onReceive: pdus.length = 1
02-25 19: 31: 01.613: D/SMS TEST (258): SmsReceiver.onReceive: ud.length = 12
02-25 19: 31: 01.613: D/SMS TEST (258): ud [0] = 0
02-25 19: 31: 01.613: D/SMS TEST (258): ud [1] = 1
02-25 19: 31: 01.613: D/SMS TEST (258): ud [2] = 2
02-25 19: 31: 01.613: D/SMS TEST (258): ud [3] = 3
02-25 19: 31: 01.613: D/SMS TEST (258): ud [4] = 4
02-25 19: 31: 01.613: D/SMS TEST (258): ud [5] = 5
02-25 19: 31: 01.613: D/SMS TEST (258): ud [6] = 6
02-25 19: 31: 01.613: D/SMS TEST (258): ud [7] = 7
02-25 19: 31: 01.613: D/SMS TEST (258): ud [8] = 8
02-25 19: 31: 01.613: D/SMS TEST (258): ud [9] = 9
02-25 19: 31: 01.623: D / SMS TEST (258): ud [10] = 10
02-25 19: 31: 01.623: D / SMS TEST (258): ud [11] = 3
02-25 19 : 31: 01.623: D / SMS TEST (258): SmsReceiver.onReceive COMPLETED!
As you can see, only the first 11 bytes of the data message are received in order.DDMS emulator control panel options Data=home, Speed=Full, Latency=None.Usage: Android Development Toolkit 16.0.1.v201112150204-238534Target AVD:Android 2.2 (API level 8)Eclipse SDK 3.6.2Is this an emulator problem? Can anyone repeat this behavior? I have been stuck with this issue for too long. Any help would be really appreciated!