Search code examples
javablackberryjava-meemulationmidlet

Sms listener with BlackBerry Application and Background Application?


I have a Gui-Application and Background-Service that runs on Blackberry device, I need to implement Sms listener that will invoke some Background-Service methods after it's acknowledges that SMS is arrived to the device, after that it will go sleep again.

I have added class to my application and it's looks like that.

import javax.microedition.midlet.*;
import javax.wireless.messaging.*;

public class SmsListener extends MIDlet implements MessageListener {

    public void notifyIncomingMessage(MessageConnection conn) {

    }

    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {

    }

    protected void pauseApp() {     

    }

    public void startApp() throws MIDletStateChangeException {
        System.out.println("Hello from midlet");        
    }       
}

When i want to initiate it it's throws me a SecurityException

Might be i am going not the right way?

How do i implement this kind (Sms listener) of Listener in that kind ( Gui-Application and Background-Service) of Application? PS: How do i test it in emulator , how do i simulate sms receiving in EMULATOR??? Thank you in advance.


Solution

  • If your MIDlet performs sensitive operations (as opening connections and such) you have to sign it or it will be asking the user for permissions every time, thus providing a horrible user experience. This is true for every phone brand, not only BlackBerries.

    In BlackBerry, you can develop your app as a MIDlet, convert the jar to a cod file, and sign it with BlackBerry Codesigning Keys. This format of MIDlet packaged as a cod file is what some people call a RIMlet.

    You can find more info on BB forums. Also check this tutorial: http://supportforums.blackberry.com/t5/Java-Development/Using-MIDLets-on-BlackBerry/ta-p/442789