16
I’m developing an application for Android that sends commands to a remote device via SMS. The commands used are all common text messages, and some of them are started with the prefix A@@
. To test the application I sent some "commands" for an Android phone 4.3 and for an Android 2.3.
When I run the app on Android 4.3, the SMS is received normally on any device, but if I use the app to send commands from an Android 2.3 the commands are received as A¿¿
on Android phone 4.3 but usually arrive as A@@
both on an Android 2.3 as on an iPhone. On the "target" device, which uses a GSM modem, the message arrives as A
(character "A" plus 2 spaces - ASCII symbol 0x20), so I suspect the upload is being done using a encoding different. The strange thing is that the symbol @
nor is it an extended ASCII character, so I wonder why it would have been encoded in another charset other than the ASCII.
Can anyone explain what’s going on? If Android device 2.3 is actually using another encoding, there is some way to force it to ASCII before sending the SMS?
The function that sends commands is the following:
@Override
public void sendCommand(String command) {
SmsManager sms=SmsManager.getDefault();
PendingIntent piSent=PendingIntent.getBroadcast(this, 0,
new Intent("SMS_SENT"), 0);
PendingIntent piDelivered=PendingIntent.getBroadcast(this, 0,
new Intent("SMS_DELIVERED"), 0);
String phone = txtPhone.getText().toString();
sms.sendTextMessage(phone, null, command, piSent, piDelivered);
}
Where the parameter command
is always the prefix concatenation with some other text, so:
String SmsPrefix = new String("A@@");
sendCommand(SmsPrefix + "AT+DEACT");
I’m pretty sure you can solve this just by using
sendMultipartTextMessage()
instead ofsendTextMessage()
Just come on out and tell me if it worked– Paulo Roberto Rosa
@Pauloroberto, thanks for the tip... I really read in some reply in the OS that this would be possible, but I just tested and stayed in the same :/ No Android 4.3 continues coming
A¿¿
– Claudio
Have you tested all devices with the same carrier/Simcard? I found very similar problems of replacing symbols in SMS and at the end my problem was in the operator.
– Luiz Cavalcanti
Well observed @molusco, Android 2.3 was with TIM chip and iPhone too.. Android 4.3 was Vivo. I’ll try switching the chips tomorrow to see what happens.
– Claudio
@mollusk, you hit the nail on the head. Any SMS sent from TIM at least to Claro arrives with the
¿
in place of@
. The Android version doesn’t really matter a bit. Prepare the answer there that this is yours! hehe..– Claudio