Developing for BlackBerry – introduction
By Radu Motisan Posted on February 19th, 2009 , 3992 Views (Rate 2.28)
Things described in this article:
- how to take screen captures from your Blackberry
- how to upgrade your BlackBerry's OS software
- what development tools you need if you want to code for BlackBerry
- a first Hello World app, including Basic controls, basic message handling, image loading and drawing
- how to upload an application to your BlackBerry and how to run it
First you should know that RIM's OS evolved in time, and that there are several versions available. My 8100 came with version 4.2 installed as you can see here:
If you need to take screen captures from your BlackBerry's screen, you might want to read this tutorial or download this tool directly.
Latest OS version for the 8100 was 4.5, so I decided to run the upgrade.
Here's another tutorial on how to do this. Here's another screenshot showing my current version:
Getting the right tools to develop my first application for BlackBerry was a real pain.
First I've tried the Visual Studio plugin for Blackberry, available on RIM's website. It worked in the simulator but it didn't work with the device - and it had nothing to do with the restricted APIs since I've only tried to put a button and display a messagebox. The compiled files were uploaded successfully to the 8100, but I couldn't find them in the programs list.
The second attempt was using Eclipse and the BlackBerry plugin. Lots of settings, if you are interested you can read more on that here. I gave it up when I managed to use the BlackBerry JDE.
So the easy way for me was to download the Blackberry JDE from this link. It also comes with a simulator in case you don't have a physical device to test.
I currently have the 4.2 version installed.
In the JDE, simply create a new Workspace, inside a new project, and there a JAVA file. You'll find some code you can use later in this post. Compiling your program will result in a .cod file. You can generate an ALX file from the menu Project->Generate ALX file. The cod and the alx can be used by the BlackBerry Desktop Manager to upload your program to the mobile device. It's straight forward, you'll manage to do this.
Alternatively you can use the Javaloader.exe to upload / delete your programs from the BlackBerry. Connect your BlackBerry to the PC via the USB Cable and use these parameters:
JavaLoader.exe -usb load your_program.cod
and to delete the program from the device:
JavaLoader.exe -usb erase -f your_program.cod
Regarding coding, you must know Java. But that's easy. My Java knowledge level was almost 0 when I've started doing this Hello World app, and by doing it, I was able to learn about creating controls dynamically ( new RichTextField), creating Timers (new Timer() .. timer.schedule ( new ToDoTask.. ), loading images (Bitmap.getBitmapResource("helloworld_jde.png")), handling paint events (public void paint(Graphics g) ) and handling user's key inputs (public boolean keyChar(char key, int status, int time) ).
The sample, including the .cod file can be downloaded here:
Basically you have everything you need there, to start doing a simple game of some kind.
And compared to Window Mobile C++ win32 API programming it's easier. But not as powerful.