MIDlet application descriptor properties

Application descriptor files have an extension of .jad. A standard MIDlet .jad file contains the following predefined attributes, and might contain additional attributes defined by the application. URL from which the .jar file can be loaded organization that provides the MIDlet suite version of the MIDlet suite, formatted as minimum number of bytes of persistent data required by the MIDlet suite the default is zero text message that appears when prompting the user to confirm deletion of the...

Manage foreground events

The system calls Application.activate when it brings an application to the foreground. Most applications do not need to override activate . Applications should perform any initialization, including any required UiApplication.pushScreen calls, in the application constructor. Because activate can be called multiple times for the same application, applications should not perform a one-time initialization in this method. An application can override activate to perform additional processing when it...

HTTP support parameters

This parameter turns on TRUE or turns off FALSE HTTP standard logging HTTP headers only . This parameter turns on TRUE or turns off FALSE HTTP debug logging HTTP data and headers . This parameter should be set to TRUE only when necessary to debug a specific problem. This parameter turns on TRUE or turns off FALSE cookie storage. If you select TRUE, BlackBerry MDS Services manages cookie storage instead of the BlackBerry device. This reduces the load on the BlackBerry device significantly....

Run on the event dispatch thread

If holding the event lock is not appropriate, create a class that implements the Runnable interface. Invoke its run method on the event dispatch thread by invoking one of the following three methods Invoke invokeAndWait Runnable to have run called on the event dispatch thread immediately. The call blocks until run completes. Invoke invokeLater Runnable to have run called on the event dispatch thread after all pending events are processed. Invoke invokeLater Runnable, long, boolean to have run...

Display stack

Screen objects are maintained in a display stack, an ordered set of Screen objects. The screen at the top of the stack is the active screen that appears to the user. When an application displays a screen, it pushes the screen to the top of the stack. When an application closes a screen, it pops the screen off the stack and displays the next screen on the stack, redrawing it as necessary. ONote Each screen can appear only once in the display stack. The VM throws a runtime exception if the same...

Organize fields horizontally

HorizontalFieldManager organizes fields horizontally. To enable horizontal scrolling, provide the Manager.horizontal_scroll style. If you do not include the horizontal_scroll parameter, the fields arrange themselves horizontally and can exceed the width of the screen, but users cannot scroll to content that is beyond the right side of the screen. BlackBerry devices do not display horizontal scrolling indicators or scroll bars. HorizontalFieldManager hfm new

Avoid using StringBufferappendStringBuffer

CLDC does not include a StringBuffer.append StringBuffer method. Appending a string buffer to another in this way creates an intermediate String object. Instead, applications should use StringBuffer dst, StringBuffer src , int offset, int length . public synchronized StringBuffer append Object obj return append String.valueOf obj public synchronized StringBuffer append Object obj if obj instanceof StringBuffer StringBuffer sb StringBuffer obj this, sb, 0, sb return this

Event listeners

Event listener interfaces are divided by event type. Each application registers to receive specific types of events. The application event queue then dispatches events to the appropriate listeners. Applications can implement the appropriate listener interfaces or override the listener methods on the various Screen objects. Most applications implement the KeyListener and TrackwheelListener interfaces and register the listeners to receive keyboard and trackwheel events. The keyboard and...

Use encoded images

The net.rim.device.api.system.EncodedImage class encapsulates encoded images of various formats. The BlackBerry device supports the following image formats .gif, .png, .wbmp, and .jpeg. Only BlackBerry devices with color screens support .jpeg images. Note The JPEGEncodedImage class requires a signature that is not available. Use EncodedImage subclasses, PNGEncodedImage and WBMPEncodedImage, to access specific properties of .png and .wbmp images, respectively. For example, PNGEncodedImage...

RIM Push request response codes

Access control error or unknown email address or BlackBerry PIN specified. The server received the request, but is unable to respond. At the present time, the server is not able to manage the request due to temporary overloading or server maintenance.

BlackBerry application descriptor properties

In addition to the MIDlet application properties, the following attributes apply to BlackBerry application .jad files. list of modules that the .cod file requires name of the module contained in the .cod file URL from which the .cod file can be loaded name of the resource bundle that the application depends on suggested position of the application icon on the Home screen Note This position might not be the actual position of the application icon on the Home screen. The BlackBerry JDE enables...

Manage drawing areas Using XYRect objects

The Graphics object represents the entire drawing surface that is available to the application. To limit this area, divide it into XYRect objects. An XYRect creates rectangular clipping regions on top of the graphics context. An XYRect object consists of two XYPoint objects. The first XYPoint object represents the top left coordinate of the XYRect, and the second XYPoint represents the bottom right coordinate. Each XYPoint represents a point on the screen, which is composed of an X coordinate...

Map transcoders

The httpcontenttranscoderslist.property file, located in the MDS config subdirectory of your BlackBerry Java Development Environment BlackBerry JDE installation, specifies how the MDS data optimization service manage the exchange of various content types between applications and content servers. The following is an example of the httpcontenttranscoderslist.property file default pass Each entry uses the following format lt InputType gt - gt lt OutputType gt lt Action gt where lt InputType gt is...

Use a WAP gateway

You can configure an HTTP connection using a WAP gateway that your service provider hosts. BlackBerry devices support WAP version 1.1 features. ONote WAP service is available on selected wireless networks only. Before you start development, contact the service provider for information on how to connect to the WAP gateway. gt To set up an HTTP connection using WAP, include the WAPGatewayIP and WapGatewayAPN parameters in Connector.open at the end of the URL. WAPGatewayAPN Mm.net.gprs Separate...

Send a RIM push request

To push data to BlackBerry devices using RIM push, send an HTTP POST request using the following format, where lt destination gt is the destination PIN or internet messaging address, lt port gt is the destination port, lt uri gt is the URI sent to the BlackBerry device, and lt content gt is a byte stream The following headers are valid for RIM push requests This header specifies a unique message ID, which can be used to cancel or check the status of a message. Typically, specify a URL in...

Create custom fields

To override default field behaviour, create a custom field. ONote Do not use Screen objects for text input. Screen does not implement disambiguation, which is required for complex input methods such as international keyboards and the 7100 series of wireless handhelds. For seamless integration of the different input methods, extend Field or one of its subclasses. Your implementation of the DrawStyle interface enables drawing styles on custom fields. See Create an interface that is consistent...

Using Bluetooth serial port connections

The Bluetooth API net.rim.device.api.bluetooth enables applications to access the Bluetooth Serial Port Profile and initiate a server or client Bluetooth serial port connection to a computer or other Bluetooth wireless technology enabled device. ONote Check for a NoClassDefFoundError when your application first accesses the Bluetooth API. This error is thrown if the system administrator restricts access to the Bluetooth API using application control. See Application control on page 16 for more...

Deploy sibling cod files

The BlackBerry Java Development Environment BlackBerry JDE creates a single .cod file and jad file for an application. If an application contains more than 64 kilobytes of byte code or resource data, the BlackBerry IDE creates a .cod file that contains sibling .cod files. Only the BlackBerry Browser supports wireless installation of a .cod file that contains sibling .cod files. Q Note If the .cod file requires signing, update the .jad file to reflect the size of the signed .cod file.

Code example Lol

The MobitexDemo.java code example demonstrates the use of the Mobitex radio layer APIs. Copyright C 2003-2005 Research In Motion Limited package com.rim.docs.samples.mobitexdemo import javax.microedition.io. import net.rim.device.api.ui. public final class MobitexDemo extends BaseApp implements MobitexDemoResource private MainScreen _mainScreen private EditField _pin private EditField _data private RichTextField _messages private SenderThread _sendThread private ReceiverThread _receiverThread...

Use the graphics context

To draw with the Graphics class, obtain a graphics context for an individual field or the entire screen. To obtain a graphics context for an individual field, invoke the Graphics constructor. Bitmap surface new Bitmap i00, i00 BitmapField surfaceField new BitmapField surface Graphics graphics new Graphics surface To obtain a graphics context for the entire screen, invoke Screen. getGraphics . Graphics graphics Screen.getGraphics To draw using any graphics context, make sure your methods perform...

Listen for datagram status events

If you want to register a datagram status listener, use a DatagramBase rather than a Datagram to hold data. DatagramBase implements the Datagram interface, but provides additional methods that are necessary to register a datagram status listener. BlackBerry Application Developer Guide Volume 1 Fundamentals dc is a DatagramConnection. Datagram d DatagramBase db DatagramBase d An error if this fails.

Code example 1

The sample applications in this guide extend the BaseApp class, which implements the following functionality extends the UiApplication class implements the KeyListener and TrackwheelListener interfaces defines variables, such as common menu items defines a method to create an application menu defines a method for menu selection defines an abstract method to exit the application Copyright C 2001-2005 Research In Motion Limited. AH rights reserved. package com.rim.samples.docs.baseapp import...

List fields

Lists enable you to create directories of items through which users can scroll and select individual or multiple entries. The BlackBerry address book is an example of a List object. You cannot directly populate the field entries with content. Your implementation of ListFieldCallback for a ListField or TreeFieldCallback for a TreeField draws the field. ListField ListField contains rows of selectable items. To display content in a ListField, set a ListFieldCallback for the list. See Create a...

Open a Bluetooth serial port connection

To open a Bluetooth serial port connection, invoke Connector.open , providing the serial port information returned by BluetoothSerialPort.getSerialPortInfo as a parameter. The connection string returned by this method specifies btspp as the protocol and one of the following items If you are opening the connection as a client, the connection string returned by getSerialPortInfo .toString contains the device ID and port number on which the server device is listening. If you are opening the...

Specify the layout for a PopupScreen

DialogFieldManager specifies the layout for PopupScreen objects. It manages layout for an icon, a message, and a list of custom fields. The icon and message appear beside each other at the top of the layout, and the custom fields appear below the message. This layout is standard for dialog PopupScreen objects. To create custom dialog boxes, extend DialogFieldManager. BitmapField bitmapField new RichTextField message new RichTextField Dialog manager message, Field.NON_FOCUSABLE LabelField...

Decode an image

To encode an image, invoke EncodedImage.createEncodedImage . This method creates an instance of EncodedImage using the raw image data in the byte array. It throws an IllegalArgumentException if the byte array that is provided as a parameter does not contain a recognized image format. private byte data new byte 2430 Store the contents of the image file. try input.read data Read the image data into the byte array. catch IOException e Handle exception. EncodedImage image...

Blackberry Sortedreadablelist

The BlackBerry JDE provides classes in the net.rim.device.api.collection.util package to manage lists of elements. SortedReadableList and UnsortedReadableList Use these classes to maintain sorted or unsorted lists of elements. The SortedReadableList class requires you to use a comparator object to sort the items in the list each item that you add to the list must be recognized as valid by this comparator. IntSortedReadableList and LongSortedReadableList Use these classes to automatically sort...

TreeField

TreeField contains parent and child nodes and presents a folder or tree relationship between items such as documents or message folders . By default, all the entries are visible. To specify whether a folder is collapsible, invoke setExpanded on the TreeField object. Icons appear beside each node that has child nodes to specify whether the node is expanded or collapsed. String fieldOne new String Main folder TreeCallback myCallback new TreeCallback TreeField myTree new TreeField myCallback,...

Define the preferred height

Note In most cases, override getPreferredHeight to make sure that the proper layout appears in custom layout managers. Your implementation of getPreferredHeight determines the preferred height of the custom field based on the relative dimensions of the field label. This makes sure that the label does not exceed the field dimensions. public int getPreferredHeight switch _shape case TRIANGLE if _labelWidth lt _labelHeight return _labelHeight lt lt 1 else return _labelHeight 4 case OCTAGON

Code example Fjp

The BluetoothSerialPortDemo.java sample is the client side of a simple Bluetooth serial port application. This application listens for data on the serial port and renders the data when it arrives. Example BluetoothSerialPortDemo.java Copyright C 2004-2005 Research In Motion Limited. The client side of a simple serial port demonstration application. This application listens for text on the serial port and renders the data when it arrives. package public class BluetoothSerialPortDemo extends...

Invert an area

Inverting an area on the Graphics object reverses the pixels by inverting the bits in each pixel value that is, 0s become 1s, 1s become 0s . Most fields use inversion to signify focus however, you can create your own focus behavior for custom fields. To invert an arbitrary portion of the Graphics object, provide coordinates, or invert a specified XYRect object. Specify the portion of the Graphics object to push onto the stack. After you invoke pushContext or pushRegion , provide the portion of...

Obfuscate a cod file

1. In the BlackBerry IDE, create your application. Tip Place the project file in a separate directory during this process. 2. Create a temporary directory. 3. Copy the .jar file created by the BlackBerry IDE to the temporary directory. 4. Extract the contents of the .jar file into the temporary directory. For example, from a command prompt type the following command 5. Delete the .cod file that was extracted as part of the .jar file. 7. Obfuscate the class files that are contained in the...

Debug using the Eclipse development environment

1. From Eclipse, click Run gt Debug. 2. Select Remote Java Application. 5. Verify that your application is listed. 7. Open the JDWP application. See Start the JDWP on page 27 for more information. 8. On the Eclipse taskbar, click Run gt Debug. 9. Under the Remote Java Application item, select an application. ONote If the following error message appears Failed to connect to remote VM. Connection timed out, increase the debugger timeout values. See Set the connection time on page 29 for more...

Listen for scroll events

Your implementation of the ScrollChangeListener interface enables your field manager to manage scroll events. Invoke setScrollListener to assign your implementation to a Manager. When the horizontal or vertical or both scrolling values change, the scrollChanged method passes in the new values. ONote Typically, listening for scrolling changes is unnecessary because your application can listen for focus changes to fields however, ScrollChangeListener can be useful in a game implementation. To...

Handle focus

To specify how fields should be given focus when the user rolls the trackwheel, override nextFocus . The direction parameter indicates the direction in which the focus moves generally, down and to the right when the trackwheel is rolled down, and up and to the left when the trackwheel is rolled up . protected int nextFocus int direction, boolean alt int index this.getFieldWithFocusIndex if alt action to perform if trackwheel is rolled up else action to perform if trackwheel is rolled down if...