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
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified
Accepted Solution

How to catch imcoming SMS without entering into INBOX?

Hi guys,

 

I am developing an app which is having SMS protocol and wondering about how to catch imcoming SMS without entering into INBOX from specific number.

 

Is it possibe ?

If yes, please suggest me.

 

Thanks in advance.

 

Please use plain text.
Developer
jdnoprada
Posts: 68
Registered: ‎03-01-2011
My Device: Not Specified

Re: How to catch imcoming SMS without entering into INBOX?

Hello,

 

If you're using the Blackberry Plug-in for Eclipse, you could try out the SMSDemo Sample by right-clicking on the package explorer > Import > Import Blackberry Samples and selecting the SMSDemo.

 

On the other hand, if you're using JDE, just open the workspace, find the Samples, and look for  SMSDemo.

 

Hope this helps :smileyhappy:

Please use plain text.
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: How to catch imcoming SMS without entering into INBOX?

Thanks for responce.

 

I did try the SmsDemo Application. But it doesn't work on my BlackBerry.

My code is here:

 

//To Send Sms

private void sendCDMAText(String nr, String message) throws IOException {
    DatagramConnection conn = (DatagramConnection) Connector.open("sms://+" + nr + ":5016");
    byte[] bytes = stringToByte(message);
    Datagram msg = conn.newDatagram(bytes, bytes.length);
    conn.send(msg);
}

private void sendSMS(String nr, String message) throws IOException {
    MessageConnection conn = (MessageConnection) Connector.open("sms://" + nr);
    TextMessage msg = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
    msg.setPayloadText(message);
    conn.send(msg);
}

private void sendTextMessage(String nr, String message) throws IllegalArgumentException, InterruptedIOException, NullPointerException, SecurityException, IOException {
    if (RadioInfo.getNetworkType() == RadioInfo.NETWORK_CDMA) {
        sendCDMAText(nr, message);
        return;
    }
    
    sendSMS(nr, message);
}

//To receive Sms

try {
    DatagramConnection dc = (DatagramConnection)Connector.open("sms://");
    while(isListening) {
         Datagram d = dc.newDatagram(dc.getMaximumLength());
         dc.receive(d);
         byte[] bytes = d.getData();
         final String address = d.getAddress();
         final String msg = new String(bytes);
         System.out.println("Message received: " + msg);
         System.out.println("From: " + address);
         break;
    }
    dc.close();
} catch (IOException e) {
    System.err.println(e.toString());
}

 

Please use plain text.
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: How to catch imcoming SMS without entering into INBOX?

Hi guys.

 

Any suggestion ?

 

Dear Peter, Can you suggest me ?

 

Thanks.

Please use plain text.
Developer
spring_suvarna
Posts: 330
Registered: ‎02-25-2009
My Device: Not Specified

Re: How to catch imcoming SMS without entering into INBOX?

Hi

 

check this

 

http://supportforums.blackberry.com/t5/Java-Develo

pment/Block-sms-from-specific-number/td-p/1348097



 

and please let me know if it works for you. It sometimes works for me and sometimes doesnt. I am still investigeting it.

 

Thanks.

Please use plain text.
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: How to catch imcoming SMS without entering into INBOX?

Thanks for your reply.

 

I've tried your code. But didn't work. Seems that this issue is impossible to code.

http://supportforums.blackberry.com/t5/Java-Development/SMS-Receive-port/m-p/494858

 

 

Please use plain text.
Developer
spring_suvarna
Posts: 330
Registered: ‎02-25-2009
My Device: Not Specified

Re: How to catch imcoming SMS without entering into INBOX?

Please use plain text.
Developer
spring_suvarna
Posts: 330
Registered: ‎02-25-2009
My Device: Not Specified

Re: How to catch imcoming SMS without entering into INBOX?

Hi Raiden,

 

Code in my earlier post works fine ! it just the timing issue. You need to process it within very few miliseconds. if you cross it, then sms wil enter into inbox. In my case we are procesing it with 10 to 20 ms.

Please use plain text.
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: How to catch imcoming SMS without entering into INBOX?

Hi,

 

Can you share your code part related timing issue ?

 

Thanks.

Please use plain text.
Developer
spring_suvarna
Posts: 330
Registered: ‎02-25-2009
My Device: Not Specified

Re: How to catch imcoming SMS without entering into INBOX?

Hi

 

Its not any specific code.

 

In the function where i was comparing the two numbers, i had few log statements and record store related code. There i commented log statements and recordstore code is writter in thread.

 

I think this happens because IO operations take some time.

Please use plain text.