Monday, May 9, 2011

Blackberry Development, An initiation

Blackberry Development, An initiation :-

Blackberry development is a hot topic now a days especially due to its own Blackberry Enterprise Server feature. Blackberry is surely a platform to look forward to due to great security features known to every body. I had been looking into this aspect since last some days and have done some decent hands on.
Developers.blackberry.com is the place to start from, unlike Android development, I found the documentations provided on blackberry website to be a little difficult to understand, but this is the place where you will get all the resources and documents .

Blackberry development can be of two forms: -
1)      Blackberry Webworks
2)      Blackberry java development

Blackberry Webworks is for the developers who are looking at browser based apps using the traditional html, CSS and javascript concepts

Blackberry java development is for the developers who want to develop native java client applications to perform some critical tasks like some database based operations or filesystem based operation

I have explored java development side of blackberry, Blackberry development is based on JAVA ME concepts. Rather any JAVA ME app can run on blackberry successfully, but additional to it blackberry has got some its own application frameworks, GUI frameworks and lot of other things to rely upon.  

For the blackberry java development kit to get installed on your system, following steps need to be followed: -

1)      download Blackberry java plugin from http://us.blackberry.com/developers/javaappdev/devtools.jsp
2)      Make sure your system has JDK 1.6 and a system with more than two JDKs configured can be a problem , if you have both JDK 1.5 and 1.6 better uninstall 1.5
3)      Double click on the set up and it will do the rest for you , you can change the installation directory if  you want


How to start application development for Blackberry Java

n      There are many sample application available with the plugin installed in your system ,
n      You can refer the documentation provided on site for reference – there are some GUI develop guides available that should be enough to start with

GUI development for Blackberry: -

            There are two parts for any blackberry project – An application and screen. Application is the point from where the initiation of the project starts. You define your default screen and initiation parameters here

A Screen class is what is rendered as a screen on your blackberry app.

Here is my sample login screen, how I had designed: -
1:  VerticalFieldManager vfm = new VerticalFieldManager();  
2:  LabelField labelScreen = new LabelField("LABEL_NAME",FIELD_HCENTER);  
3:  labelScreen.setFont(getFont().derive(Font.ITALIC));  
4:  labelScreen.setBorder(BorderFactory.createSimpleBorder(new XYEdges(0, 0, 3, 0)));  
5:  labelScreen.setMargin(0,0,20,0);  
6:  vfm.add(labelScreen);  
7:  vfm.setBorder(Border.STYLE_SOLID, BorderFactory.createSimpleBorder(new XYEdges(2,2,2,2)));  
8:  vfm.setMargin(20, 20, 20, 20);  
9:  HorizontalFieldManager hfmLogin = new HorizontalFieldManager();  
10:  LabelField labelLogin = new LabelField("LOGIN_LABEL : -");  
11:  labelLogin.setFont(getFont().derive(Font.BOLD));  
12:  hfmLogin.add(labelLogin);  
13:  EditField loginId =new EditField();  
14:  loginId.setBorder(BorderFactory.createBevelBorder(new XYEdges(TOPMOST, RIGHTMOST, BOTTOMMOST, LEFTMOST)));  
15:  loginId.setMargin(0, 0, 20, 0);  
16:  hfmLogin.add(loginId);  
17:  vfm.add(hfmLogin);  
18:  HorizontalFieldManager hfmPass = new HorizontalFieldManager();  
19:  LabelField labelPass = new LabelField("PASSWORD_LABEL : - ");  
20:  labelPass.setFont(getFont().derive(Font.BOLD));  
21:  hfmPass.add(labelPass);  
22:  PasswordEditField password = new PasswordEditField();  
23:  password.setBorder(BorderFactory.createBevelBorder(new XYEdges(TOPMOST, RIGHTMOST, BOTTOMMOST, LEFTMOST)));  
24:  password.setMargin(0,0,20,0);  
25:  hfmPass.add(password);  
26:  vfm.add(hfmPass);  
27:  ButtonField submitLogin = new ButtonField("Login",FIELD_HCENTER);  
28:  submitLogin.setEnabled(true);  
29:  vfm.add(submitLogin);  
30:  submitLogin.setCommand(new Command(new CommandHandler() {  
31:  public void execute(ReadOnlyCommandMetadata metadata, Object context) {  
32:     UiApplication.getUiApplication().pushScreen(new MyScreen());  
33:           }  
34:        }));  
35:  this.add(vfm);  

As can be inferred from the code above, I have used Vertical layout. There are three types of layouts available: -

1)      Vertical
2)      Horizontal
3)      Flow
4)      Grid

I have assigned action to my submit button by assigning it a command, here I am pushing a new screen onto the application stack on the action of button click

This is it for GUI part of Blackberry; I dealt with the database part as well. But I think that will need one more blog entry

Reference Site: -
            http://developers.blackberry.com