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
gunar
Posts: 64
Registered: ‎09-02-2008
My Device: 8830, 8100

Update SMS

Hi!

 

I want to manipulate an incoming/outgoing SMS by changing the sende/receiver for incoming/outgoing SMSes... I saw that there is no API to do this, or to do another workaround: delete the original SMS and create another SMS in the same folder with the original SMS content but a different receiver/sender ...

 

I am 99% sure that this is no possible, just wanted to ask  if you knowit something like this is possible, it doesn't matter on which version ...

 

Best regards!

gunar

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Update SMS

Gunar,

 

I haven't found any way to manipulate the SMS messages once they hit the folder. The only thing that you can do (AFAIK) is listen for an SMS message using the MessageConnection class. 

 

See the article here:

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

 

Please use plain text.
Developer
gunar
Posts: 64
Registered: ‎09-02-2008
My Device: 8830, 8100

Re: Update SMS

Hi, thanks for this solution, but I already was aware of these ....

 

I saw that there is no API, and I was hoping for some workaround, but I will have to live with this ...

 

I wonder why BlackBerry made an API for editing mail (not only for editing mail), net.rim.blackberry.api.mail, but they didn't make anything for SMS?

 

Br,

gunar

Please use plain text.
Developer
yosoh
Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Re: Update SMS

Hi,

 

I dont want to start a new thread as my topic is related to sms listener. In the article different ways to listen for sms messages only the Datagramconnection approach works for me. MessageListener does not at all work and the method notifyIncomingMessage(MessageConnection conn) never gets called when new SMS arrives.

 

Does the  MessageListener  approach work for you people? I am not using any port.

 

thanks,

 

yosoh. 

--------------------------------------------------
problemSolved() ? kudosPlease():kudosPlease();
Please use plain text.
Developer
gunar
Posts: 64
Registered: ‎09-02-2008
My Device: 8830, 8100

Re: Update SMS

Hi!

 

It's all related to how you create the MessageConnection object:

Here is an example of how it works for me:

 

private MessageConnection msgConn;

private void messageConnApproach(){
        try{
            msgConn = (MessageConnection)Connector.open("sms://:0");
            msgConn.setMessageListener(this);
        }
        catch(IOException ex){
            // handle exception
        }
    }

 

 And then you should have no problems :

 

public void notifyIncomingMessage(MessageConnection conn) {
        try{
            Message message = conn.receive();
            /**
             * The message is TextMessage if it is an SMS...
             * */
            if(message instanceof TextMessage){
                TextMessage msg = (TextMessage)message;
                /**
                 * Address comes in "sms://" flavor...
                 * */
                String address = msg.getAddress().substring(6);
                //msg.setAddress("+40723445566");
                String textMessage = msg.getPayloadText();
                // Do whatever you want ...
            }
        }
        catch(IOException ex){
            ex.printStackTrace();
        }
        catch(Exception ex){
           
        }
    }

 

I hope it helps ...

 

Br,

gunar

Please use plain text.
Developer
yosoh
Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Re: Update SMS

thanks a lot gunar. now i observed that my notifyIncomingMessage was being called but the message format was different. it works now.

 

thanks again,

 

regards,

 

yosoh 

--------------------------------------------------
problemSolved() ? kudosPlease():kudosPlease();
Please use plain text.