03-09-2009 12:46 PM
Hey, Im pulling my hair out here trying to get basic SMS code to work, and I must be missing something. Im using a T-Mobile Curve 8900 and Im developing a simple app to programmatically send SMS (no special listener on the other end - simply send a plain text message). Here's the code (copied from SMSdemo)
MessageConnection mc; try { mc = (MessageConnection)Connector.open("sms://:3590"); if(mc==null) throw new IOException(); TextMessage m = (TextMessage) mc.newMessage(MessageConnection.TEXT_MESSAGE , "//" + mAddress + ":3590"); m.setPayloadText(mMsg); mc.send(m); mc.close(); }
It doesnt throw any exceptions, it just simply...doesnt send. Nothing in the Curve's outbox, nothing on the receiver phone. I've tried different phone number formats for constructing the address (15551234567, 5551234567, +15551234567) but none work. This is sending to/from a GSM network. Any clues? Do I need a different port, and if so which?
Also, for the issue of including CDMA, whats the proper way to handle this? I can use MessageConnection for GSM-GSM (well, in theory), and Datagram for CDMA-CDMA and CDMA-GSM, but what about GSM-CDMA?
Thanks for any help you can provide!
03-09-2009 01:04 PM
09-30-2010 08:50 AM
Hi !
I think your problem is with using ports. you need to use port 0.
this port is the port which remote application is listening.
if you are sending sms to other phone, and you want to see in its inbox, use port zero.
if you want to send on specific port - you need to use DatagramConnection and you need set UDH field to true. follow this link:
http://myhowto.org/java/j2me/22-sending-and-receiv
it describes how you can correctly form and send binary sms using DatagramConnection.
regards,
Alibek