Archive for September, 2009|Monthly archive page
I’m looking for one engineer (who has worked with BlackBerry) for a fun little project. It’s a paid project, not just a hobbyist idea.
If you’re interested, please leave a comment, and I’ll email you. Thanks!
Suppose you’d like to create a BlackBerry application that will launch when you send an SMS message to the appropriate port. It’s possible, but there are a number of non-obvious (and not-necessarily-documented) tricks. I spent a few too many hours on experimenting to figure out precisely what works, and I’m posting my notes here to save you some time:
- Apparently your application has to be a MIDlet, not a “CLDC application” (RIMlet). I was a little surprised when I read this in the BlackBerry Java Dev forum, since it would undoubtedly be trivial for RIM to allow either type of application to register with the PushRegistry and get launched. So I did a few tests (with a “MIDlet-Push-1” Jad property analogous to the way the RIMlet uses the “MIDlet-1” property), and, indeed, the PushRegistry doesn’t seem to work for RIMlets, but it works fine for MIDlets. (Note: it’s still theoretically possible that there’s a way to make it work for RIMlets, but I couldn’t find the trick.)
- Adding a custom property to your Jad file is really easy if you know the trick. 😉 The trick is that (in the BlackBerry JDE) you can add the Jad file to the project (in the same way you add source files and images). Once you’ve added the Jad file to the project, you can add properties and then they won’t get overwritten when you rebuild. But before you add it, you should modify the project properties (setting the application type to MIDlet) and then build the project once, so that it will create for you a correct initial Jad file to use.
- Before your application closes, you should dynamically re-register with the PushRegistry. This was the trickiest one to guess! If your MIDlet is launched by the PushRegistry — and you open the corresponding connection to read the SMS message that launched your MIDlet — this automatically unregisters your MIDlet from the PushRegistry. With other handsets, once you’re registered with the PushRegistry (either statically in the Jad or dynamically from within the application), you stay that way until you actively unregister it. But not BlackBerry. Or at least not with the BlackBerry simulator that comes with the BlackBerry JDE 4.2.0. I assume the behavior is the same in other versions and on the device, but I’m not certain…
- How do you simulate the SMS to test the application launch with the PushRegistry? I explained that here.
If you’re writing a BlackBerry Java application that sends and/or receives SMS text messages, naturally you need to be able to test the application on the simulator. And naturally the simulator doesn’t really send SMS messages, so you need to know how to get the simulator to exchange simulated SMS messages with another instance of the simulator.
This is very easy to do. You can do it with the SmsDemo that comes in the BlackBerry JDE’s sample applications bundle — even though the SmsDemo’s JavaDoc seems to imply that you can’t. If you look in the code of SmsDemo.java (usually found at C:\Program Files\Research In Motion\BlackBerry JDE <version>\samples\com\rim\samples\device\smsdemo), the JavaDoc says the following:
This program requires the associated server component found in the com.rim.samples.server.smsdemo package under the samples directory in your JDE installation.
That’s not precisely true. It doesn’t require the server component — it can actually send demo messages from one instance of the simulator to another, as long as you set the sms-source-port of the one to be the sms-destination-port of the other, and vice-versa. There are just a few quick steps and notes for launching the two instances: Continue reading