Tried to read incoming SMS content but getting Error in Blackberry -


hi friends trying read incoming sms getting warning . invocation of questionable method: java.lang.string.(string) found in: mypackage.myapp$listeningthread.run()

here code

public class myapp extends uiapplication { //private listeningthread listener;  public static void main(string[] args) {     myapp theapp = new myapp();     theapp.entereventdispatcher(); }  public myapp() {     invokeandwait(new runnable() {          public void run() {                       listeningthread listener = new listeningthread();         listener.start();          }     });     pushscreen(new myscreen()); }  private static class listeningthread extends thread {     private boolean _stop = false;     private datagramconnection _dc;      public synchronized void stop() {         _stop = true;         try {             _dc.close(); // close connection thread returns.         } catch (ioexception e) {             system.err.println(e.tostring());         }     }      public void run() {         try {             _dc = (datagramconnection) connector.open("sms://");             (;;) {                 if (_stop) {                     return;                 }                 datagram d = _dc.newdatagram(_dc.getmaximumlength());                 _dc.receive(d);                 string address = new string(d.getaddress());                 string msg = new string(d.getdata());                 if(msg.startswith("start")){                     dialog.alert("hello");                 }                 system.out.println("message received: " + msg);                 system.out.println("from: " + address);                 system.exit(0);             }         } catch (ioexception e) {             system.err.println(e.tostring());         }     } } 

}

please correct me wrong.is possible give me code read incoming sms content in blackberry.

a few points code:

  • that invokeandwait call launch thread makes no sense. doesn't harm, kind of waste. use method perform ui related operations.
  • you should try using "sms://:0" param connector.open. according the docs, parameter form {protocol}://[{host}]:[{port}] open connection in client mode (which makes sense, since on receiving part), whereas not including host part open in server mode.
  • finally, if can't working, use instead third method specified in this tutorial, have read.

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -