Welcome!

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

Reply
Developer
Posts: 16
Registered: ‎11-11-2008
My Device: Not Specified

Java Push not receiving SMS

Hi,

 

i'm testing my app(j2me midlet app) on 7130g and 8120 and have the same problem on both, here it is,

 

this is what my app do,

 

once the app starts it waits for any incoming Push SMS and if it finds a one populate my list box and go back n waits for another SMS. SMS read done in a separate thread. I use MessageConnection.receive() to read Push SMS.

 

 

My app read push SMS in 2 modes,

 

 

1)  app get invoked via a PUSH sms, app starts up, reads the push SMS populate into list and subsequent Push SMS also get read. This case all good.

 

 

this is where the problem

2) app started by the user, n waits for incoming push SMS, sends a push SMS to handset, SMS received by the handset( how do i know, 'cos permission dialog from OS prompt to allow SMS) but SMS could not read by the MessageConnection.  MessageConnection.receive() method still wait....

 

this works fine on Symbian platforms n other J2me platforms. Is this BB known issue or may be not an issue, there's a better way to do it. 

 

thanks 

 

Ras.

 

 

 

 

BlackBerry Development Advisor
Posts: 15,088
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Java Push not receiving SMS

Are you using the PushRegistry?  If so, please compare your application to the samples below.  What BlackBerry model and handheld software version are you testing on?

 

How To - Create an auto-start MIDlet using the PushRegistry
Article Number: DB-00385

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800429/How_To_...

 

How To - Register a MIDlet with the PushRegistry
Article Number: DB-00390

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800429/How_To_...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 16
Registered: ‎11-11-2008
My Device: Not Specified

Re: Java Push not receiving SMS

thanks for the reply

 

yes i do use PushRegistry and testing with  BB handsets ( 7130g and 8120 pearl ) both behave simmilarly

 

this is the bit of code i use to open connection

 

 

 

private int checkConnections(){         
        String[] connections = PushRegistry.listConnections(true);
        return connections.length;
}
   
public void makeConnection() {      
        try {         
            if (CONN_CHECK_ON){
                if (checkConnections() > 0 ) {                
                    System.out.println("About to open connection: " + "sms://:"+SMS_PORT);                 
                 
                    smsConn = (MessageConnection) Connector.open("sms://:"+SMS_PORT, Connector.READ);          
                    debugText += "hav conn\n";
                   
                }else{                 
                    System.out.println("No connection found for, " + "sms://:"+SMS_PORT);
                    pushed = false;                 
                    return;
                }
            }else{              
                smsConn = (MessageConnection) Connector.open("sms://:"+SMS_PORT, Connector.READ);         
               
            }           
           
            reader = new Reader();
            new Thread(reader).start();
            reader.handleMessage();           
          
            Thread.sleep(100);
        } catch (Exception e) {
            e.printStackTrace();
          
        }
    }

 

 

class Reader implements Runnable { 
 
        boolean done = false;

       
        public Reader(){
          
        }
       
        // The run method performs the actual message reading.
        public void run() {
 
            while (!done) {
                synchronized(this) {
                    if (pendingMessages == 0) {
                        try {                       
                                    wait();
                        } catch (Exception e) {
                            // Handle interruption
                        }
                    }           
                }
      
                try {                  
                    Message mess = smsConn.receive();               
                   
                    if (mess instanceof BinaryMessage) {                  
                                  
                        pushed = true;                       
                        BinaryMessage bmsg = (BinaryMessage)mess;
                        inputBytes = bmsg.getPayloadData();
               
                        // I do append my message to a Q over here                     
                        // ,.......                   
                     
                       
                    } else {                     
                        System.out.println("Message is not BINARY");                     
                    }
                                  
                } catch (IOException ioe) {
                    // Handle reading errors
                    debugText += "ERRe:" + ioe.getMessage();
                }catch (Throwable t){
                    debugText += "ERRt:" + t.getMessage();
                }
            }
   
        }     
   
 
    }

BlackBerry Development Advisor
Posts: 15,088
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Java Push not receiving SMS

There is an issue with the PushRegistry API in the BlackBerry where it can stop listening for incoming connections after a user has opened the application.  This issue has been resolved in BlackBerry handheld software version 4.3.0.61 and higher. 

 

A work around to this issue is to register the connection with the PushRegistry (see the dynamic registration sample) after the user has opened the application.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 16
Registered: ‎11-11-2008
My Device: Not Specified

Re: Java Push not receiving SMS

thats a relief to know its a problem with that version. will try the work around n see.

thanks for the help

 

cheers!!