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
arindamhit
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel
Accepted Solution

How to send the SMS to a particular or a list of numbers??

Hi

I want to send the SMS to a particular number or a group of number. As i got some way in this below link: SMS Send

, i tried with that. But after sending the sms, it is not received on the particular number. Means it is not delivering. I have written the below codes::

 

          if (field == mCbSaveContact)
		{
                   sendSms();
                }

 private void sendSms() {
	// TODO Auto-generated method stub
		
		 UiApplication.getUiApplication().invokeLater(new Runnable()
		    {
		    
		        public void run() {
		        	
		        	DatagramConnection dgConn; 
		        	try {
						dgConn = (DatagramConnection)Connector.open("sms://9014409192");
						byte[] data = "Test Message".getBytes();
						Logger.out("AddContact","data value");
			        	Datagram dg = dgConn.newDatagram(dgConn.getMaximumLength());
			        	dg.setData(data, 0, data.length);
			        	Logger.out("AddContact","after setting the data");
			        	dgConn.send(dg);
			        	Logger.out("AddContact","Sending SMS success !!!");
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
		        	    } 
		       });


   Please help..

Please use plain text.
Developer
simon_hain
Posts: 16,003
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to send the SMS to a particular or a list of numbers??

invokelater is not a thread, and everything that blocks should be done on a separate thread.
http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
arindamhit
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel

Re: How to send the SMS to a particular or a list of numbers??

So you want to run this part of code in a thread??

Please use plain text.
Developer
simon_hain
Posts: 16,003
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to send the SMS to a particular or a list of numbers??

i suggest that.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.