It's been a while since I had the same issue, so hopefully someone has a more useful reply than me. (That would be nice). But here's what I learned when I looked at it:
The difference between JavaME and Android (in regards to SMS sending) is that Android lets you catch incoming SMS on the standard port, while JavaME forces you to use any other port.
A message sent with sendTextMessage()
from Android, is identified as an instance of TextMessage
on the JavaME platform. But since you can't specify a port on Android, it is send on the standard port - which you can't receive with JavaME.
So you ofcourse look at sendDataMessage()
, because it lets you specify a port number. The problem is: A message sent with sendDataMessage()
from Android, is identified as an instance of BinaryMessage
on the JavaME platform. So the JavaME code listening for a TextMessage
will never trigger, since it's a BinaryMessage
it's receiving.
The only solution I could find, was therefor to add some code for when a BinaryMessage
was received. Slightly different ways of decoding the incoming message, but otherwise doing the same thing.
Sadly you can't do this since you write you don't have the JavaME source, but here's how it could look:
String receivedSMS;
public void notifyIncomingMessage(MessageConnection conn) {
try {
Message msg = conn.receive();
if (msg instanceof TextMessage) { // Message sent from J2ME device
TextMessage tmsg = (TextMessage) msg;
receivedSMS = tmsg.getPayloadText();
} else if (msg instanceof BinaryMessage) { // Message sent from Android device
BinaryMessage bmsg = (BinaryMessage)msg;
byte[] ta = bmsg.getPayloadData();
receivedSMS = new String(ta);
}
} catch (Exception e) {
}
}
That's the only solution I could find back then. If anyone has a better one, I'd like to know too. :-)