Here I am using the Blackberry simulator 8520. I want to receive an sms in my Blackberry application without notifying the inbox (silently).
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
// TODO Auto-generated method stub
try
{
DatagramConnection dc =(DatagramConnection)Connector.open("sms://");
for(;;)
{
Datagram d = dc.newDatagram(dc.getMaximumLength());
dc.receive(d);
byte[] bytes = d.getData();
String address=new String(bytes);
String msg = new String(bytes);
String message=msg.toString();
add(new RichTextField(message));
add(new RichTextField(address));
}
catch(Exception e)
{
e.printStackTrace();
}
}
});
The SMS message will have to be sent to a port other than port 0 (the default)
Connector.open("sms://:1500");and your program will have to be listening on the port when the message arrives. If you send an SMS message from a BlackBerry to a port other than 0 it is actually sent to 0 or the port specified so if there is no server listening to the port the message is delivered to the inbox.