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
Highlighted
New Contributor
Posts: 6
Registered: ‎07-13-2013
My Device: curve 9320
My Carrier: wind mobile

Receiving Sms. [Newbie]

Hey, I was wondering if anyone could make a class which all it does it listens for sms msgs, and then one it finds one it alerts it in a box. Also I would like the varible holding the msg to be public so I can accsess the var from other class's. Anyone up fot the chanllange. I tried my self but failed.

Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: Receiving Sms. [Newbie]

Try This:

new Thread()
{
   public void run() 
   {
      try
      {
         _dc = (DatagramConnection)Connector.open(_openString);
         for(;;)
         {
             Datagram da = _dc.newDatagram(_dc.getMaximumLength());
             _dc.receive(da);
             address = new String(da.getAddress());    // mobile number
             msg = new String(da.getData());           // message
         }
      } 
      catch ( IOException e) 
      {
      }
   }
}.start();

 Check whether it works for you or not

 

Hit Like if you found your solution

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Receiving Sms. [Newbie]

I recommend the search facility - see the box near the top right.  Type SMS in there and you will find the KB articles which  developer_aman_arora seems to have used.  For example:

 

http://supportforums.blackberry.com/t5/Java-Development/Different-ways-to-listen-for-SMS-messages/ta...

 

and

 

http://supportforums.blackberry.com/t5/Java-Development/Different-ways-to-send-SMS-messages/ta-p/445...

 

In addition, you will find other Threads for people who have asked similar questions.

 

Good luck in your Blackberry development.