Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

New Developer
Posts: 2
Registered: ‎01-22-2010
My Device: 8310
My Carrier: Sprint

SMS between java applications on Blackberries between CDMA and GSM



I have seen related post on the question in the forum, but with out a solution. So here is what i am trying to do..


Send port directed SMS between two java application on Blackberry across different networks. Given the fact that MessageConnection works on GSM and DatagramConnection works on CDMA the implementation is based on the radiotype. The application sends on port 5016(to be compatible with non-blackberies) and listens at port zero for all SMS


Below is the matrix of the output. The application sends at 5016 and listens at port 0 for GSM and sends and receives at port 0 for CDMA




Sprint (CDMA)     ATT(GSM)        Verizon (CDMA)             TMobile (GSM)


 Sender                     Received                     Received              Received


Received              Sender             Not Received                 Not Received 


Received             Received               Sender                         Received


Not Recieved    Not Received       Not Received                       Sender












Sending part



public  void sendMessage(CryptoMidlet midCrypto, String phoneNumber, Vector v, boolean port, boolean isBinary) throws Exception {

        // Itereate tru the message vector and send it
        int size = v.size();
        if(smsconn != null && !Utility.isCDMA()) { //GSM
            for(int i=0; i<size ; i++) {
                String targetAddress = (port) ? "sms://+" + phoneNumber + ":5016" : "sms://+" + phoneNumber;
                MessageConnection messageConnection = (MessageConnection)Connector.open(targetAddress);
                if(isBinary) {
                    BinaryMessage bMessage = (BinaryMessage)messageConnection.newMessage(MessageConnection.BINARY_MESSAGE);
                    byte[] encodedMessage = (byte[])v.elementAt(i);
                } else {
                    TextMessage msg = (TextMessage)messageConnection.newMessage(MessageConnection.TEXT_MESSAGE);
                    msg.setPayloadText((String) v.elementAt(i));
          } else if(datagramConnection != null && Utility.isCDMA()) { //CDMA
                byte[] finalMessage  = null;
                for(int i=0; i< size; i++) {
                   DatagramConnection datagramConnection = (DatagramConnection)Connector.open((port) ? "sms://+"+phoneNumber+ ":0" : "sms://+" + phoneNumber);
                   if(isBinary) {
                       finalMessage = (byte[])v.elementAt(i);
                   } else {
                       String msgTemp = (String)v.elementAt(i);
                       finalMessage = msgTemp.getBytes("UTF8");
                   Datagram datagram = datagramConnection.newDatagram(finalMessage,finalMessage.length);
                   datagramConnection.send(datagram) ;



Listening part



public void initalizeSMSConnection() {

        boolean success = true;
        if (smsconn == null && !Utility.isCDMA()) {
            String smsConnection = null;
            smsConnection = "sms://:0";
            try {
                smsconn = (MessageConnection)Connector.open(smsConnection);

            }catch (Exception ioe){
        } else if (datagramConnection == null && Utility.isCDMA()) {
            String smsConnection = "sms://:0";
            try {
                datagramConnection = (DatagramConnection)Connector.open(smsConnection);

            }catch (Exception ioe){


Does any one has a solution to how this could work between all BB across different carriers on different n/w


New Developer
Posts: 13
Registered: ‎12-26-2009
My Device: 8120
My Carrier: tmobile

Re: SMS between java applications on Blackberries between CDMA and GSM

I'm also working on a similar project and have tried sending/receiving on port zero to be more 'cdma friendly' but with the same results??  basic failure for cdma networks to receive messages sent from a gsm device...