Blackberry Development Notes

by Jessica Brown

Touch Screen Development

Retrieve the current orientation of the touch screen

Import net.rim.device.api.system.Display
Call Display.getOrientation()

Note that Display does not exist in JDEs prior to 4.7

Using Ifdefs to support one code base for multiple JDEs

Files that use the preprocessor must have //#preprocess as their first line to enable pre-processing on the file.

Then, where you want to use preprocessed code, use ifdef or ifndef blocks. Eg:

//#ifndef jde_4_7
Your code here; // code that will run if jde_4_7 is defined
//#ifndef jde_4_7

Command Line Builds

USB Cable Loading an App

When you plug in the (powered-on) device via USB a removable drive should appear in my computer. If you are prompted by windows to install drivers for the Blackberry, do so before proceeding. Blackberry USB Drivers can be obtained from Blackberry’s website

  • With the phone connected via USB, open a command prompt to the “cable” folder under output.
  • Run javaloader -u load myapp.cod at the command prompt to install myapp on the phone. (or you can use a relative path to the cod file if you are in another directory when you run this command)
  • Run javaloader -u erase myapp at the command prompt to uninstall myapp from the phone. (do not prefix myapp with a path, and do not include the .cod to uninstall). Note: if you get a module is in use dialog, make sure you’ve exited the app on the phone, and if it still complains add -f after erase to put it in force mode.

Installed programs will be under the “Downloads” icon on the device. If a different version of the same application was loaded over the air, it may result in a message on attempted app startup about duplicate class definitions. If this is the case javaloader can be used to list the applications on the phone (javaloader -u dir), to identify the duplicated version, which can then be removed with javaloader.

Eclipse Blackberry Plugin/Simulators

Blackberry Simulator Reset

When debugging in Eclipse, sometimes you may come across a situation where you want to reset the blackberry device settings to undo any accidental customization (such as rearranging menus on the device) and remove all persisted files on the device (such as removing any cached app settings).

To do this, run the clean.bat file in the eclipse plugin’s simulator’s directory. (eg: for the 4.7.0 simulator, this will likely be “C:\Program Files\eclipse\plugins\net.rim.ejde.componentpack4.7.0_4.7.0.53\components\simulator\clean.bat”)


Compatibility Mode on Touch Screen Devices

Touch-screen support is a new feature in the 4.7 OS/JDE. If you build an app to run on a touch-screen device like the storm using JDE prior to 4.7, unless you set a special JAD setting, the app will run in “compatibility mode”. Differences in compatibility mode include things like the app does not run at the native resolution of the device but will run centered on the screen in portrait mode (at the resolution of older blackberries), flipping being disabled, and other UI differences.

RTSP support in Simulator

The 4.6.0 JDE & simulator supports both HTTP and RTSP based playback well. The 4.7.0 simulator does not support RTSP, as blackberry “does not support all of the multimedia codecs on the simulator itself [and is] relying on the device to be the proper testing ground”, so testing RTSP in version 4.7.0 requires testing on a physical device.