blackberry - Phone freezes when listening for incoming sms's -


Why does the following code freeze all the tasks on the phone? The app reads incoming SMS, but the app does not open. After the application is clicked, the phone is freezing what I am doing wrong. I appreciate any help.

  try {// A datagram connection is designed to listen for any incoming SMS. Datagram connection _ DC = (DataMaracon connection) connector.open ("SMS: //"); Datagram D = _dc.newDatagram (_dc.getMaximumLength ()); _dc.receive (d); Byte [] bytes = d.getData (); String address = d.getAddress (); // SMS address has been placed on the string. String msg = new string (bytes); // The body of the SMS is put on a string. } Hold (Exception Me) {}    

Run your code inside the thread (this is the most Is bad) code which I have written):

  new thread () {public zero run () {datagrav connection _dc = (datamacron connection) connector. Open ("SMS: //"); // A datagroup connection has been created to listen for any incoming SMS. Datagram D = _dc.newDatagram (_dc.getMaximumLength ()); _dc.receive (d); Byte [] bytes = d.getData (); String address = d.getAddress (); // SMS address has been placed on the string. String msg = new string (bytes); // The body of the SMS is put on a string. } }.Start();    

Comments