0

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.

bharath
  • 14,283
  • 16
  • 57
  • 95
hackp0int
  • 4,052
  • 8
  • 59
  • 95
  • Can you explain how do i do it with Blackberry application? – hackp0int Sep 08 '11 at 09:00
  • @IamStalker To simulate SMS in emulator , mine is Sun Java ME SDK 3.0 , click the `WMA Output Window` when executing the program. –  Sep 22 '11 at 06:13

2 Answers2

0

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

Mister Smith
  • 27,417
  • 21
  • 110
  • 193
  • The question is may i register it with my application that already uses alternate entry point and gui ? – hackp0int Sep 08 '11 at 10:03
  • 1
    Hum, for alternate entry points and GUI i'd use a full fledged BB app, extending UiApplication instead of midlet. – Mister Smith Sep 08 '11 at 10:11
  • How do i create listener for sms then? How do i test the sms receiving on Emulator? – hackp0int Sep 08 '11 at 11:11
  • Create listener: http://supportforums.blackberry.com/t5/Java-Development/Different-ways-to-listen-for-SMS-messages/ta-p/445062 – Mister Smith Sep 08 '11 at 11:58
  • Test in emulator: send yourself from the emulator an SMS to the emulator using the messages application. To view the emulator phone number in order to autosend a sms, push on BB emulator Simulate menu -> incoming call. – Mister Smith Sep 08 '11 at 12:00
  • And perhaps it is possible to set up a midlet as BG process with alternate entry point, but I never tried. The easiest way to go in my opinion is to make a native BB app. – Mister Smith Sep 08 '11 at 12:09
  • Do you have any class that you use to setup Sms Listener on BB App? – hackp0int Sep 08 '11 at 13:51
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/3274/discussion-between-iamstalker-and-mister-smith) – hackp0int Sep 08 '11 at 14:00
  • It isn't complicated. It can be a simple app (can be configured as auto-run on startup if needed) with an infinite loop opening a connection of one of the 3 kinds described in the create listener comment. Check the SMSDemo sample project included in the BlackBerry JDE. – Mister Smith Sep 08 '11 at 14:04
  • hi i've checked it and it's like nothing i've copy pasted the code from the SMSSEND RIM DEMO, and nothing it does not work – hackp0int Sep 08 '11 at 16:43
0

Why don't you use the example in Oracle documentation ? SMS is JSR 120. Download this pdf about JSR 120 which contains examples.