Application or Port Directed SMS: How to Send an SMS to a Java app/MIDlet
It’s a common task, but a confusing one. As Java becomes more widely supported on mobile phones, one of the most obvious application needs is the ability to send SMS messages to an application and have the application take some action based upon the content of the SMS message.
However, while J2ME will let an application receive messages, it will not let the MIDlet interact directly with the phone’s SMS inbox. Instead, applications only receive messages that were addressed to their specific port number. For more information on how to receive these messages from an application running on a phone, refer to the JSR-120 and/or JSR-205 specifications published by the Java Community.
From within your MIDlet, it is relatively easy to send an SMS message to a particular port, because you just include the port number in the recipient address (sms://phonenumber:port).
However, it is not so easy (or in many cases even possible) to send an SMS message to a specific port from a conventional SMS client.
We’ve supported a relatively easy (if obscure) way of sending an SMS message to a specific port in NowSMS since early 2004.
With NowSMS 2007 and later releases, it is easier, as the “Send Text Message” web form will now include a “Destination Port” field. Alternatively, when submitting via a URL request, include “&DestPort=xxxx” or “&SourcePort=xxxx” in the URL request to specify a destination and/or source port. Or, the destination port can be specified in the recipient phone number using the format phonenumber:port. (Note: When using the phonenumber:port format, if multiple recipients are specified, the same destination port will be applied for all recipients, that being the first destination port encountered in the recipient list.)
The above example sends a message to port 3333 (hex value, decimal value = 13107). The text of the message is “this is a test”, it has just been URL escaped for encoding in a URL.
From the web form, use the “Send Binary Message Other” form, specify a user data header (UDH) of: 060504xxxxyyyy Where xxxx is the destination port in hex, and yyyy is the source port in hex. (If the source port is not important, replace it with 0’s.) In the “Binary Data” field, put in your text, and leave the DCS as 0. (If you want to send binary data, put the hex string for the binary data in the “Binary Data” field, and use a binary DCS value such as 4.)
If you are posting via direct URL submission, specify the user data header using the parameter “&UDH=060504xxxxxxxx”, and submit the text as you normally would using the “&Text=” parameter.
The above example sends a message to port 3333 (hex value, decimal value = 13107). The source port in this example is 0. The text of the message is “this is a test”, it has just been URL escaped for encoding in a URL.
For comments and further discussion, please click here to visit the NowSMS Technical Forums (Discussion Board)...