Thursday, October 8, 2009

File size limit of wireless downloads

The maximum size of a COD file, which can be downloaded wirelessly, varies based on a number of factors. These factors include the BlackBerry Device Software version, the BlackBerry Enterprise Server™ version, the BlackBerry JDE version, and the type of browser used to install the application (for example, BlackBerry Browser connected to a BlackBerry MDS or BlackBerry Mobile Data Service, or Internet Browser using the BlackBerry Internet Service™).

Using BlackBerry JDE 3.6 and 3.7

When using BlackBerry JDE 3.6 and 3.7, the maximum COD file size that can be downloaded wirelessly, using a browser, is 128 KB. This number includes a maximum limit of 64 KB for application data (code) and 64 KB for resource data (images or files).

Note: Each section must also be under the 64 KB limit; therefore, you cannot complete a wireless installation of a COD file that contains 20 KB of application data and 100 KB of resource data. There are no exceptions to this limit for applications built with BlackBerry JDE 3.6 and 3.7.

To work around this, build your application so that it consists of several smaller COD files. Place some of your object code or resources into a Library project. When built, this will produce multiple COD files that must be smaller than the limit.

To build a Library project, complete the following steps:

1. In the BlackBerry JDE, create a second project.
2. Right-click the project and select Properties.
3. On the Application tab, select Library as the Project Type.
4. Move some of your classes or resources from the main application into this library project to reduce the size of your main application.

The library project becomes part of the runtime classes on the BlackBerry device.

1. In the main application, import this package to be able to use the classes.
2. Compile both applications.

You now see two distinct COD files (one for your application, and one for the library).

1. Change your JAD file to allow the user to download the two COD files, as shown below:

....
RIM-COD-URL: myLibrary.cod
RIM-COD-URL-1: myApp.cod
RIM-COD-SHA1: 65 39 3f 54 d8 ef 6e 43 72 37 db 5e 7a 27 89 84 f8 e0 30 9b
RIM-COD-SHA1-1: 88 02 c3 1c 00 19 e8 bb e5 1a 3f f8 28 8e b5 57 5b dd 48 14
RIM-COD-Size: 33128
RIM-COD-Size-1: 46996
...

Note: Always place the libraries at the top of the JAD list so they are downloaded first.

Using BlackBerry JDE 4.0 and Later

BlackBerry JDE 4.0 introduced the concept of sibling COD files. If an application is too large to fit within the 128 KB limit (64 KB of application data and 64 KB of resource data), sibling COD files are created and packaged into a single main COD file. Sibling COD files are a series of COD files that are suffixed with -#, where # is incremented for each sibling COD file. These sibling COD files are then packaged into a main COD file that has a basic ZIP structure. The sibling COD files adhere to the 128 KB (64 KB + 64 KB) size limit. To determine if your application contains sibling COD files, you can attempt to open the COD file with WinZip®. If the COD file contains sibling COD files, you can open it and View or Extract the sibling COD files in the same way as a ZIP file.

Using the BlackBerry Browser to Install

When using a BlackBerry Device Software or a BlackBerry Enterprise Server earlier than 4.0, the maximum COD file size that can be downloaded wirelessly, using a browser, is 128 KB (64 KB of application data and 64 KB of resource data).

BlackBerry MDS or BlackBerry Mobile Data Service 4.0 and later paired with a device running BlackBerry Device Software 3.8 or later is able to download a COD file greater than 128 KB that contains sibling COD files.

Note: If the COD file does not contain sibling COD files, the limit is still 128 KB. BlackBerry MDS or BlackBerry Mobile Data Service can extract the sibling COD files from the main COD file, and send them individually to the BlackBerry Browser.

Using the Internet Browser to Install

When using the Internet Browser through the BlackBerry Internet Service, the maximum COD file size that can be installed wirelessly is 128 KB (64 KB of application data and 64 KB of resource data). The Internet Browser does not have the ability to install a COD file that contains sibling COD files, regardless of their size.

To support this browser, the sibling COD files should be extracted from the main COD file and placed individually on a web server. To extract them, use WinZip. Make sure you extract the sibling COD files to a different directory other than the location of the main COD file as the first sibling COD file will have the same name as the main COD file.

After the COD files have been extracted, reference each of them in the JAD file. Use the example above to update the JAD file.

Note: BlackBerry JDE 4.1 and later will automatically create a JAD file that references all sibling COD files, thus, no editing of the JAD file is needed.

Optimized installation

It is recommended that sibling COD files be extracted from the main COD file and placed individually on a web server instead of packaged in the main COD file. This allows both the BlackBerry Browser and Internet Browser to install the application. It is also more efficient for the web server. The BlackBerry Enterprise Server does not store COD files, so every time a sibling COD file that is packaged in a main COD file is requested by a device, the BlackBerry MDS or BlackBerry Mobile Data Service must download the entire main COD file to extract the single requested sibling COD file. As a result, the BlackBerry MDS or BlackBerry Mobile Data Service will download a main COD file multiple times (one time for every sibling COD file it contains).

How to attached microsdcard on simulator.

To use a computer file system as a microSD card, complete the following steps:

1. Open the BlackBerry JDE.
2. From the Edit menu, click Preferences.
3. On the Simulator tab, select a simulator running BlackBerry® Device Software 4.3.x.
4. On the Simulator tab, click Memory.
5. Select the Use PC filesystem for SD Card files check box.
6. Type the location of the folder to use as a microSD card.


1. Open the BlackBerry JDE.
2. From the Edit menu, click Preferences.
3. On the Simulator tab, select a simulator running BlackBerry® Device Software 4.3.x.
4. On the Simulator tab, click Memory.
5. Select the Use PC filesystem for SD Card files check box.
6. Type the location of the folder to use as a microSD card.

Please Note: Using the Browse button to select the location of the folder to use as a microSD card in BlackBerry JDE only allows selection of a file and not a folder; the location must be corrected manually to represent a folder.

1. Click OK.

How to View Event Log on Storm.9530

Your BlackBerry's Event Log displays your system's recently run events and processes. If you're experiencing a problem with your BlackBerry or having an issue with a specific application or service, information from the Event Log can be helpful for troubleshooting. And it can be a good BlackBerry hygiene to clear out the log, to keep your device running smoothly.

To delete your list of events, hit the BlackBerry MENU key while any event is highlighted and then click "Clear Log." A dialogue box will then pop up asking if you're sure you want to delete the log. Once you confirm the deletion, your log will be cleared.

To access your Event Log on BB Storm 4.7 simulator, Press and hold the "?123" key to lock the numeric keyboard, the press ", 5 , 5" ie.(comma 5 comma 5)

To access your Event Log in your bb device, go to your Home Screen, hold down the ALT key and then type "LGLG."

How to create Single .ALX(ActiveX Layout) file for loading build from Desktop Manager.

In Blackberry many times it is required that we have to import different number of jar file in our project and we need to create single .alx and multiple number of cods are created.so for uploading build to HH(Handheld).
So we can use the down code to create single .alx file for laoding build to HH.
The below code is used to add more files into the project.

file1.cod
file2.cod
file3.cod




If you want to import more applications using single .alx file, then you need to include separate application tag for each and every individual application/project you need to import.

For example :

<application id="myApp"><name ></name><description > myApp </description><version >1.0</version><vendor >Research In Motion Limited</vendor><copyright >Copyright (c) 2009 Research In Motion Limited</copyright><fileset Java="1.38"><directory ></directory><files > myApp.cod</files></fileset></application>



You need to add a new tag entry for each of the applications you need to import.

how to set background image in VerticalFieldManager.

As we use color in background of VeticalFieldManager we can also use Images in background.use the following sample code to draw background images in verticalFieldManeger.
class MSBMainScreen extends MainScreen
{
/*MSBMainScreen can be use as the base class for the other UserInterface Screen of your application. when you create new class for UI Screen just extend your class to MSBMainScreen*/
private VerticalFieldManager _container;//instance of VerticalFieldManager
private Bitmap _BG;
/* instace of Bitmap to be draw in VerticalFieldManager paint method */

public MSBMainScreen()
{
super();

setTitle( "Main Screen Background Hack" );

_BG = Bitmap.getBitmapResource( "background.png" );

_container = new VerticalFieldManager( Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR ) {
protected void paint( Graphics g )
{
// Instead of these next two lines, draw your bitmap
int y = MSBMainScreen.this.getMainManager().getVerticalScroll();

g.drawBitmap( 0, y, _BG.getWidth(), _BG.getHeight(), _BG, 0, 0 );

super.paint( g );
}

// The keydown and navigation overrides are a workaround
// for an optimization hack RIM performed, perhaps assuming that
// Managers would not try to take control of painting on
// a MainScreen.
protected boolean keyDown( int keycode, int status )
{
invalidate();

return super.keyDown( keycode, status );
}

protected boolean navigationMovement( int dx, int dy, int status, int time )
{
invalidate();

return super.navigationMovement( dx, dy, status, time );
}
};

super.add( _container );
}


public void add( Field field )
{
_container.add( field );
}

public void delete( Field field )
{
_container.delete( field );
}

// Implement the rest of the field manipulation functions to redirect ro the new container

}

Wednesday, October 7, 2009

Building first HelloWorld app on Blackberry platform

Learn how to use the freely available BlackBerry JDE to develop, debug, and test BlackBerry applications.

BlackBerry supports Java 2 Platform, Micro Edition (J2ME) and ships with a complete Connected Limited Device Configuration/Mobile Information Device Profile (CLDC/MIDP) implementation. Although Blackberry devices run applications that use only the standard MIDP APIs (commonly referred to as MIDlets), developers can also tap into BlackBerry-specific APIs to take advantage features such as sophisticated user interfaces.

This article introduces the freely available BlackBerry Java Development Environment (JDE), which allows you to develop, debug, and test BlackBerry applications. It goes on to demonstrate how to create a simple HelloWorld application that exploits some of BlackBerry's own APIs.

The BlackBerry JDE
The BlackBerry JDE includes an integrated development environment (IDE) for BlackBerry applications and Blackberry simulation tools that you can use to see exactly how the applications will act on a real BlackBerry device. The BlackBerry JDE also contains a number of working sample applications.

Before moving on, download the BlackBerry JDE. At the time of this article's writing, it was in version 4.0.1.

Installation of the JDE requires that you have the Java 2 Platform, Standard Edition (J2SE) v1.4 running. InstallShield walks you through the JDE installation. When you choose a complete installation type, it should create a Research in Motion program group in your Start menu.




Prepare to Say Hello
Start up the Blackberry JDE by going to Start -> All Programs -> Research In Motion -> BlackBerry Java Development Environment 4.0 -> JDE. You should see the RIM development environment. Use the Files tab of the Workspace view to drill down into the com\rim\samples\device folder. There you will see a number of sample application projects that you can dissect to your heart's content. One of them is a HelloWorld application (see Figure 1).


Figure 1. Browsing Through the JDE's Samples

Since life is not very educational if everything is handed to you on a silver platter, this tutorial demonstrates how to build your own HelloWorld application—which actually does exactly what the HelloWorld application that ships as an example does.


Figure 2. Creating a New Workspace

Like many other IDEs, Blackberry projects are collectively housed in units called workspaces. Create a workspace by going to the File menu and choosing the New Workspace… option. Specify a Workspace name of HelloWorldWorkspace as Figure 2 shows. Here, you can also specify a directory in which to create the workspace. This article uses the default directory locations provided by the IDE.


Figure 3. Creating a New Project in the HelloWorldWorkspace Workspace

After creating the new workspace, choose the Project menu and then the Create New Project… option. Name the project HelloWorldProject as Figure 3 shows.

Next, choose the File menu and the New… option. In the subsequent Create new file window, make sure the Java File type is selected and specify "HelloWorld.java" for the File name, as Figure 4 shows.


Figure 4. Creating a New File Named HelloWorld.java

At this point, the IDE creates a barebones Java class with the following code in it:


package ;

class HelloWorld
{
}

Of course, this code does nothing. It is your job to populate the HelloWorld class with something worthwhile (more on that in a bit). But before that, you need to associate your HelloWorld java file with the HelloWorldProject you created earlier. To do this, simply right click in the code editor area and select the Insert into Project option. From the subsequent project selection window, choose the HelloWorldProject.




Say HelloWorld
At this point, you are ready to create your HelloWorld application. Since you want your HelloWorld application to provide a graphical user interface (GUI), you need your HelloWorld class to extend the net.rim.device.api.ui.UiApplication class. (Download the code for the HelloWorld application from the zip file that accompanies this article.)

Your BlackBerry application starts like a typical J2SE application does, with a main method. If you are an experienced MIDlet programmer, you should notice something weird here. A MIDlet starts at the startApp() method, but BlackBerry applications start at main:


class HelloWorld extends net.rim.device.api.ui.UiApplication
{
public static void main(String[] args)
{
HelloWorld instance = new HelloWorld();
instance.enterEventDispatcher();
}
public HelloWorld()
{
pushScreen(new HelloWorldSample());
}
}

The first thing you do in the main method is create an instance of your application by calling its constructor. The constructor uses the HelloWorld class' parent class (UiApplication) method of pushScreen to display a screen. You haven't defined the SalutationScreen class yet, but rest assured, you'll get to that. After calling the constructor, call your new instance's enterEventDispatcher method. This method allows your application to start handling various events that the BlackBerry device may send to the application (e.g., UI-centric events).

Create a new class in the HelloWorldWorkspace and HelloWorldProject, as you did before, but this time call the new class SalutationScreen.java. The SalutationScreen class is what will actually present a Hello World message to your application user. SalutationScreen.java is shown below:


import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;

class HelloWorldSample extends MainScreen
{
public HelloWorldSample ()
{
super();
LabelField applicationTitle =
new LabelField("Hello World Title");
setTitle(applicationTitle);
RichTextField helloWorldTextField = new RichTextField("Hello World!");
add(helloWorldTextField);
}
public boolean onClose()
{
Dialog.alert("Bye World!");
System.exit(0);
return true;
}
}

The HelloWorldSample Class Dissected
The HelloWorld class extends from the net.rim.device.api.ui.container.MainScreen class, giving your simple application consistency with other native BlackBerry applications. It also provides such features as a default menu with a Close menu item for exiting out of your application, which the user also can invoke by pressing the BlackBerry Escape key.

To add a title to your simple application, create a new net.rim.device.api.ui.component.LabelField object:


LabelField applicationTitle =
new LabelField("Hello World Title");

The code above contains a field with the text "Hello World Title". You can always learn more about this API call, as well as other APIs, by taking a look at the API Reference that installed with the JDE. To view the API reference, go to the Help menu and choose the API Reference option or simply press shift+F1 (see Figure 5).


Figure 5. Using the JDE's API Reference

After creating your LabelField GUI component, add it to the screen by using the add method you inherited from your ancestor class net.rim.device.api.ui.Screen.

You also inherit the onClose method from the net.rim.device.api.ui.Screen, which is fired when your screen (Salutation Screen) closes. In reaction to the closing event, the application uses the alert method of the net.rim.device.api.ui.component.Dialog class to display a popup on the screen stating a message of "Bye World!":


public boolean onClose()
{
Dialog.alert("Bye World!");
System.exit(0);
return true;
}




A Real World "HelloWorld"
At this point, you are ready to see your simple application in action. But before doing so, you need to make sure that your HelloWorldProject has been marked as Active. Doing so tells the BlackBerry simulator which applications it should run. Go to the Project menu and select the Set Active Projects… option. Make sure the HelloWorldProject is checked and click OK.


Figure 6. Build the HelloWorldProject and Launch the Simulator

Next, go to the Build menu and select the Build All and Run option (see Figure 6).



Figure 7. Launch the BlackBerry Simulator

Now, you should see the BlackBerry Simulator launch as shown in Figure 7.

At this point, you can use the up and down arrow keys to find your HelloWorldProject application amongst the installed applications on the simulator. The up and down arrows simulate the thumb wheel of a real BlackBerry device (see Figure 8).


Figure 8. Pick the HelloWorldProject Application

To choose the application, you can either press the Enter key on your keyboard or the Enter button on the simulator's keyboard. To see how the BlackBerry simulator closely mimics the real life device, you can alternatively click the thumb wheel of the emulator (as shown in Figure 9) to launch the HelloWorld application.



Figure 9. Thumbwheel of the Simulator

Whichever method you chose to launch the application, your efforts should yield the HelloWorld application on the screen of your emulator (see Figure 10).

To exit out of the application, click the Escape button of your keyboard or the Escape button on the side of the BlackBerry emulator. You should see the Bye World! alert as shown in Figure 11.

Clicking OK should bring you back to the application chooser screen. You can click the File menu and the Exit option to exit out of the simulator.




Figure 10. The HelloWorld Application Launched




Figure 11. The Bye World! Alert

Multiple Simulation Environments Included
By default, the BlackBerry JDE 4.0.1 uses the BlackBerry 7290 device simulator, but it offers a large number of BlackBerry simulation devices. To choose one, select the Edit menu and the Preferences… option. In the subsequent Preferences window, choose the Simulator tab and pick among the list of available device profiles. Figure 12 shows the selection of the BlackBerry 7100t profile.

Upon a subsequent run of the simulator, you will be able to run the HelloWorld application on the chosen simulator device (see Figure 13).




Figure 12. Choose a Profile for Device Simulation


Figure 13. Run Your Application on a Simulator

Just Scratching the Surface
This article demonstrated how to develop Java applications for the BlackBerry device. The BlackBerry JDE provides a powerful environment in which you can develop, debug, test, and simulate applications.

Like many IDEs, the BlackBerry JDE provides developers with such features as code completion for ease of development. It also lets you look under the hood of your application during the debugging process, allowing you to set breakpoints, step through code line by line, and view variable state information.
The simple Hello World application showcased in this article barely scratches the surface of the rich applications you can create for the BlackBerry. Being familiar with the BlackBerry JDE, you should now feel comfortable going through the numerous sample applications the JDE offers.