BlackBerry Dev

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
TheIrishPhilosopher
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 20
Joined: Wed Aug 10, 2011 11:18 am
Current Project: ASP.NET (work related)
Favorite Gaming Platforms: Amstrad 464+, Gameboy, PS3, PC
Programming Language of Choice: c#
Location: Belfast

BlackBerry Dev

Post by TheIrishPhilosopher »

Hi Folks
I started looking at Blackberry development for work recently, and made a few notes, hopefully this helps someone else out there

Setting up the Development Environment for Blackberry
Java Development

Blackberry applications are written in J2ME (Java 2 Microedition), this is a subset of the Java SE (Standard Edition) which can be downloaded from:
https://cds.sun.com/is-bin/INTERSHOP.en ... TypeFilter
After you install the Java toolkit, run the cmd prompt in Windows and type:

Java version
If installed correctly, you should see the Java version number printed on the console window.
Blackberry Development Tools
The Blackberry development tools and other resourses can be found at:
http://us.blackberry.com/developers/
From this page you can sign up for a developer account, create new themes for the Blackberry and read the Blackberry resource documents.
Eclipse IDE and Blackberry add-in Tools
Firstly you have to install the Eclipse Development Environment, you can get it from:
http://www.eclipse.org/
You can install the basic Java Eclipse platform, next you will have to download the Blackberry development tools – download the Blackberry toolkit from the blackberry.com website. In Eclipse choose:
Help>Software Updates and click the Available Software tab
Under the available software tab, click Add Site. Then click Archive and browse for the zip file that you downloaded from blackberry.com, click install and the Eclipse IDE will be ready to develop Blackberry applications.

Downloading Simulators
Every version of the JDE Blackberry component pack comes with a set of default simulators, however RIM provides simulators for all Blackberry devices – including the new Storm Model. These can be found at:
http://us.blackberry.com/developers/resources/

Installing Desktop Software
With the Blackberry device provided by Nitec, there is a disc that contains the Blackberry Desktop Manager – this allows you to load your application straight onto a Blackberry device to Test it. It can also be downloaded from:
http://uk.blackberry.com/
Code Signed Codes
For basic applications, you can compile and run on real Blackberry devices with no Code signing Keys. However if you want to use further features – like Cryptography, Persistant storage.
Generally it takes 2 to 3 days to get your Signed Codes from RIM and cost about £12
http://us.blackberry.com/developers/jav ... dekeys.jsp
Life is essentially about exploring, finding our way through a maze of faces, ideas..and different beers!
User avatar
TheIrishPhilosopher
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 20
Joined: Wed Aug 10, 2011 11:18 am
Current Project: ASP.NET (work related)
Favorite Gaming Platforms: Amstrad 464+, Gameboy, PS3, PC
Programming Language of Choice: c#
Location: Belfast

Re: BlackBerry Dev

Post by TheIrishPhilosopher »

Creating a Hello World Application for Blackberry
To create a New Blackberry project:
1. Click the File Menu
2. Choose New Project
In the Project dialog box, choose Blackberry project from the Blackberry folder – as shown below:

Click Next and name your project HelloWorld and click Finish. Your Eclipse Workspace should contain a single project in the Package Explorer on the left-hand side.
When expanded, the folder should contain a folder called src, which is where your Source Code will be placed, and a reference to NET_RIM_BLACKBERRY, which is the Blackberry runtime containing the Blackberry API – as shown below.


Creating the Main Application Class
Right-click the HelloWorld Project icon in the package Explorer, and from the pop-up menu, select:
New > Class
In the dialog, type the following values
1. Package: com.Blackberry
2. Name: HelloWorldApp
3. Superclass: net.rim.device.api.ui.UiApplication


You get the following generated source code:
Package com.Blackberry;
Import net.rim.device.api.ui.UiApplication;
Public class HelloWorldApp extends UiApplication
{
Public HelloWorldApp()
{

}
}
Creating the Main Screen Class
Click New>Class again and fill in the following values
1. Package: com.Blackberry
2. Name: HelloWorldMainScreen
3. Superclass: net.rim.device.api.ui.container.MainScreen
Leave all other values as default and click finish to create the following source code.
Package com.Blackberry;
Import net.rim.device.api.ui.container.MainScreen;
Public class HelloWorldMainScreen extends MainScreen
{

}

Filling in the HelloWorld Class
First add the code for HelloWorldApp.java:
Package com.Blackberry;
Import net.rim.device.api.ui.UiApplication;
Public class HelloWorldApp extends the UiApplication
{
Public HelloWorldApp()
{
HelloWorldMainScreen mainScreen = new HelloWorldMainScreen();
pushScreen(mainScreen);
}

Public static void main(String[]args)
{
HelloWorldApp app = new HelloWorldApp();
App.enterEventDispatcher();
}
}

Notice here we create the constructor for HelloWorldApp() and reference the MainScreen class, then we push the MainScreen class onto the Blackberry device. Then we create the main thread of the program.

Filling in the MainScreen Class
Enter the following code into the HelloWorldMainScreen.java class
Package com.Blackberry;
Import net.rim.device.api.ui.component.LabelField;
Import net.rim.device.api.ui.container.MainScreen;
Public class HelloWorldMainScreen extends MainScreen()
{
Public HelloWorldMainScreen()
{
LabelField labelField = new LabelField(“Hello World”);
Add(labelField);
}
}
This creates a LabelField, which will display text onto the screen.

Running the Simulator
Running the Default Blackberry simulator is as easy as clicking the Run icon on the Eclipse IDE:









Adding a Title and Icon to the Application
The Application title and version are accessed through the project properties dialog. In Eclipse, it is accessed by right-clicking the name of the project in the left-hand pane, selecting Properties and clicking Blackberry Project Properties


If you don’t specify an application title, the Blackberry will use your project name of HelloWorldApp, which isn’t very user friendly, so change the Title field to Hello World!.
Life is essentially about exploring, finding our way through a maze of faces, ideas..and different beers!
Post Reply