Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE Manual
Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE Manual

Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE Manual

Version: 4.7.0
Hide thumbs Also See for JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE:
Table of Contents

Advertisement

Quick Links

BlackBerry Java Development Environment
Version: 4.7.0
Development Guide

Advertisement

Table of Contents
loading

Summary of Contents for Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVELOPMENT GUIDE

  • Page 1 BlackBerry Java Development Environment Version: 4.7.0 Development Guide...
  • Page 2 SWD-549284-1212112738-001...
  • Page 3: Table Of Contents

    Restrict the touch screen direction............................Receive notification when a drawable area of the touch screen changes..............Receive notification when the orientation of the touch screen changes................ Working with the accelerometer of a BlackBerry device......................Types of accelerometer data..............................Accelerometer..................................Retrieve accelerometer data at specific intervals.......................
  • Page 4 Respond to touch screen events............................Keyboard on a BlackBerry device with a touch screen....................... Change the state of the keyboard on a BlackBerry device with a touch screen............. Display the keyboard on a BlackBerry device with a touch screen.................. Hide the keyboard on a BlackBerry device with a touch screen..................
  • Page 5 Retrieve a registered runtime object............................ Retrieve an unregistered runtime object..........................3 Creating connections.................................. Network gateways..................................Using the BlackBerry Enterprise Server as an intranet gateway..................Using the wireless service provider's Internet gateway....................Retrieve the wireless network name............................ Connections..................................... Use HTTP authentication..............................
  • Page 6 Application manager..................................Retrieve information about a BlackBerry Java Application....................Communicate with another BlackBerry Java Applications....................Determine the services that are available to a BlackBerry Java Application..............Application control..................................Allow a BlackBerry device application to request access to resources................Code modules....................................
  • Page 7 7 Localizing BlackBerry device applications..........................Multilanguage support................................... Files required for localization................................ Manage localization files for a suite of BlackBerry device applications................... 8 Controlling access to APIs and application data........................Check if a code signature is required............................Java APIs with controlled access..............................
  • Page 8 Distribute an application for testing............................ Distributing an application from a computer..........................Create an application loader file..............................Install a BlackBerry device application on a specific device...................... 100 Specifing supported versions of the BlackBerry Device Software.................... 100 11 Glossary......................................102 12 Provide feedback..................................104...
  • Page 9: Creating User Interfaces

    The user interface APIs initialize simple Screen objects. Once you create a screen, you can add fields and a menu to the screen and display it to the BlackBerry device user by pushing it on to the UI stack. The menu object has associated menu items that are runnable objects, which perform a specific task when the BlackBerry device user selects one of the items.
  • Page 10: Create A Screen

    The BlackBerry® Java® Virtual Machine maintains Screen objects in a display stack, which is an ordered set of Screen objects. The screen at the top of the stack is the active screen that the BlackBerry device user sees. When a displays a screen, it pushes the screen to the top of the stack.
  • Page 11: Manage A Drawing Area

    Manage a drawing area The Graphics object represents the entire drawing surface that is available to the BlackBerry® device application. To limit this area, divide it into XYRect objects. Each XYPoint represents a point on the screen, which is composed of an X co- ordinate and a Y co-ordinate.
  • Page 12: Touch Screen Orientation And Direction

    Direction refers to the top of the drawing area of the screen, relative to the location of the BlackBerry logo. If you change the direction that a Screen supports, the change takes effect the next time the Screen orientation of the device changes.
  • Page 13: Restrict The Touch Screen Direction

    Development Guide Touch screen orientation and direction Invoke net.rim.device.api.system.Display.getOrientation(). int orientation = Display.getOrientation(); Restrict the touch screen direction Import the following classes: • net.rim.device.api.ui.Ui • net.rim.device.api.ui.UiEngineInstance Invoke net.rim.device.api.ui.Ui.getUiEngineInstance(). UiEngineInstance _ue; _ue = Ui.getUiEngineInstance(); Invoke net.rim.device.api.ui.UiEngineInstance.setAcceptableDirections(byte flags) and pass the argument for the direction of the Screen. _ue.setAcceptableDirections(Display.DIRECTION_WEST);...
  • Page 14: Working With The Accelerometer Of A Blackberry Device

    The BlackBerry® Storm device includes an acclerometer that senses the orientation and acceleration of the device. When a BlackBerry device user moves the device, the accelerometer senses the movement in 3-D space along the x, y, and z axis. A BlackBerry device user can change the orientation of the device which can change the display direction of a screen for a BlackBerry device application between portrait and landscape.
  • Page 15: Retrieve Accelerometer Data At Specific Intervals

    Retrieve accelerometer data at specific intervals If a BlackBerry® device application opens a channel to the accelerometer when the application is in the foreground, when the application is in the background, the channel pauses and the accelerometer is not queried. If a BlackBerry device application invokes AccelerometerSensor.Channel.
  • Page 16: Query The Accelerometer When The Application Is In The Background

    Development Guide Working with the accelerometer of a BlackBerry device Invoke Channel.close() to close the channel to the accelerometer. channel.close(); Query the accelerometer when the application is in the background Import the following classes: • net.rim.device.api.system.AccelerometerChannelConfig; • net.rim.device.api.system.AccelerometerSensor.Channel; Create a configuration for a channel to the accelerometer.
  • Page 17: Retrieve Accelerometer Readings From A Buffer

    Development Guide UI components Invoke AccelerometerSensor.openChannel() to open a channel to the accelerometer. Channel bufferedChannel = AccelerometerSensor.openChannel ( Application.getApplication(), channelConfig ); Retrieve accelerometer readings from a buffer Import the following classes: • net.rim.device.api.system.AccelerometerData; • net.rim.device.api.system.AccelerometerSensor.Channel; Query the buffer for accelerometer data. AccelerometerData accData;...
  • Page 18: Create A Dialog Box

    Development Guide UI components CheckboxField myCheckbox = new CheckboxField("First checkbox", true); Add the UI component to your extension of a Screen class. mainScreen.add(myCheckbox); Create a dialog box Import the following classes: • net.rim.device.api.ui.Manager • net.rim.device.api.ui.container.HorizontalFieldManager • net.rim.device.api.ui.container.PopupScreen Create an instance of a subclass of the Manager class. Manager manageLayout = new HorizontalFieldManager( VERTICAL_SCROLLBAR);...
  • Page 19: Create A Text List That Can Be Filtered

    UI field that consists of a single text input field and a list of selectable elements. A word that a BlackBerry® device user enters into the text input field filters the elements in the list.
  • Page 20 Development Guide UI components KeywordFilterDemoScreen screen = new KeywordFilterDemoScreen (this,_keywordField); screen.add(_keywordField.getKeywordField()); screen.add(_keywordField); pushScreen(screen); 10. To create a method that populates and returns a vector of Country objects containing data from text file, In the method signature, specify Vector as the return type. public Vector getDataFromFile() Create and store a reference to a new Vector object.
  • Page 21: Create A Check Box

    • net.rim.device.api.ui.component.RadioButtonField Create an instance of a RadioButtonGroup. RadioButtonGroup rbGroup = new RadioButtonGroup(); Create an instance of a RadioButtonField for each option you want to make available to the BlackBerry® device user. RadioButtonField rbField2 = new RadioButtonField("Second field"); Invoke RadioButtonGroup.add() to add the RadioButtonFields to the RadioButtonGroup and make sure the BlackBerry device user can select only one option at a time.
  • Page 22: Create A Text Field

    Development Guide UI components Create a text field Create a read-only text field that allows formatting Import the net.rim.device.api.ui.component.RichTextField class. Create an instance of a RichTextField. RichTextField rich = new RichTextField("RichTextField"); Create an editable text field that has no formatting and accepts filters Import the following classes: net.rim.device.api.ui.component.BasicEditField •...
  • Page 23: Create A Progress Bar Field

    Development Guide UI components • net.rim.device.api.ui.component.BasicEditField Create an instance of an AutoTextEditField. AutoTextEditField autoT = new AutoTextEditField("AutoTextEditField: ", ""); Create a progress bar field Import the net.rim.device.api.ui.component.GaugeField class. Create an instance of a GaugeField. GaugeField percentGauge = new GaugeField("Percent: ", 1, 100, 29, GaugeField.PERCENT);...
  • Page 24: Create A Field To Display A Parent And Child Relationship Between Items

    Development Guide UI components Create an instance of a ListCallback. ListCallback myCallback = new ListCallback(); Set the call back of the ListField to be the ListCallback. myList.setCallback(myCallback); Use the ListCallBack object to add items to the ListField. myCallback.add(myList, fieldOne); myCallback.add(myList, fieldTwo); Add the ListField to the MainScreen.
  • Page 25: Add A Ui Component To A Screen

    Development Guide UI components To repaint a TreeField when a node changes, create a class that implements the TreeFieldCallback interface and implement the TreeFieldCallback.drawTreeItem method. In the following code sample, the TreeFieldCallback.drawTreeItem method uses the cookie for a tree node to draw a String in the location of a node.
  • Page 26 Development Guide UI components private String _label; private int _shape; private Font _font; private int _labelHeight; private int _labelWidth; Implement constructors to define a label, shape, and style of the custom button. public CustomButtonField(String label) { this(label, RECTANGLE, 0); public CustomButtonField(String label, int shape) { this(label, shape, 0);...
  • Page 27 Development Guide UI components public int getPreferredWidth() { switch(_shape) { case TRIANGLE: if (_labelWidth < _labelHeight) { return _labelHeight << 2; } else { return _labelWidth << 1; case OCTAGON: if (_labelWidth < _labelHeight) { return _labelHeight + 4; } else { return _labelWidth + 8;...
  • Page 28 Development Guide UI components protected void paint(Graphics graphics) { int textX, textY, textWidth; int w = getWidth(); switch(_shape) { case TRIANGLE: int h = (w>>1); int m = (w>>1)-1; graphics.drawLine(0, h-1, m, 0); graphics.drawLine(m, 0, w-1, h-1); graphics.drawLine(0, h-1, w-1, h-1); textWidth = Math.min(_labelWidth,h);...
  • Page 29: Create A Menu Item

    "Open the Contacts Demo application"; Implement run() to specify the behaviour of the menu item. In the following code sample, if a BlackBerry device user clicks the text "Open the Contacts Demo application" in the menu of the BlackBerry device application, if a Contact exists, we allow an application called ContactsDemo to receive events by invoking ContactsDemo.enterEventDispatcher().
  • Page 30: Adding Menu Items To A Blackberry Device Application

    Adding menu items to a BlackBerry device application You can use the Application Menu Item API, in the net.rim.blackberry.api.menuitem package to add menu items to a BlackBerry® device application. You can use the ApplicationMenuItemRepository class to add or remove menu items from a BlackBerry device application.
  • Page 31: Arrange Ui Components

    Development Guide Arrange UI components Arrange UI components To arrange components on a screen, use BlackBerry® API layout managers. The following four classes extend the Manager class to provide predefined layout managers: VerticalFieldManager • • HorizontalFieldManager FlowFieldManager • • DialogFieldManager Import the following classes: •...
  • Page 32: Align A Field To A Line Of Text

    UI events Respond to UI navigation events When you create a BlackBerry® device application, use the new Screen navigation methods and avoid using the TrackwheelListener. If your existing BlackBerry device application implements the TrackwheelListener, update your BlackBerry device application to use the new Screen navigation methods.
  • Page 33: Respond To Blackberry Device User Interaction

    Types of touch screen events A TouchEvent class represents a touch input action that a BlackBerry® device user performs. A TouchGesture class represents an event that is a combination of touch input actions that a BlackBerry device user performs. Action...
  • Page 34 Development Guide Touch screen events Action Event Result On the shortcut bar, this action displays a tooltip that describes the action that the icon represents. touch the screen twice net.rim.device.api.ui On a web page, map, picture, or presentation attachment, this quickly action zooms in to the web page, map, picture, or presentation .TouchGesture.TAP...
  • Page 35: Respond To Touch Screen Events

    Development Guide Touch screen events Action Event Result In a text field or in Month view in a calendar, this action moves the empty rectangle cursor in the same direction. touch the screen in two net.rim.device.api.ui This action highlights the text between the two locations or the locations at the same list of items, such as messages, between the two locations.
  • Page 36 Development Guide Touch screen events • net.rim.device.api.ui.Manager • net.rim.device.api.ui.Screen Create a class that extends the Manager class, the Screen class, the Field class, or one of the Field subclasses. public class newButtonField extends ButtonField { In your implementation of the touchEvent(TouchEvent message) method, invoke TouchEvent.getEvent().
  • Page 37 Development Guide Touch screen events TouchGesture gesture = message.getGesture(); switch(gesture.getEvent()) { case TouchGesture.SWIPE: if(gesture.getSwipeDirection() == TouchGesture.SWIPE_SOUTH) { Dialog.alert("Downward swipe occurred"); return true; return false; Respond to a user sliding a finger to the left quickly on the screen Import the following classes: •...
  • Page 38 Development Guide Touch screen events Respond to a user sliding a finger to the right quickly on the screen Import the following classes: • net.rim.device.api.ui.TouchEvent • net.rim.device.api.ui.TouchGesture • net.rim.device.api.ui.Field • net.rim.device.api.ui.Manager • net.rim.device.api.ui.Screen Create a class that extends the Manager class, the Screen class, the Field class, or one of the Field subclasses. public class newButtonField extends ButtonField { In your implementation of the touchEvent(TouchEvent message) method, invoke TouchEvent.getEvent().
  • Page 39 Development Guide Touch screen events In your implementation of the touchEvent(TouchEvent message) method, invoke TouchEvent.getEvent(). Check if the value that TouchEvent.getEvent() returns is equal to TouchEvent.CLICK. protected boolean touchEvent(TouchEvent message) { switch(message.getEvent()) { case TouchEvent.CLICK: Dialog.alert("CLICK occurred"); return true; return false; Respond to a user touching the screen twice quickly Import the following classes: •...
  • Page 40 Development Guide Touch screen events • net.rim.device.api.ui.TouchEvent • net.rim.device.api.ui.Field • net.rim.device.api.ui.Manager • net.rim.device.api.ui.Screen Create a class that extends the Manager class, the Screen class, the Field class, or one of the Field subclasses. public class newButtonField extends ButtonField { In your implementation of the touchEvent(TouchEvent message) method, invoke TouchEvent.getEvent().
  • Page 41 Development Guide Touch screen events Respond to a scroll action Import the following classes: • net.rim.device.api.ui.TouchEvent • net.rim.device.api.ui.TouchGesture • net.rim.device.api.ui.Field • net.rim.device.api.ui.Manager • net.rim.device.api.ui.Screen • net.rim.device.api.system.Display • net.rim.device.api.ui.component.Dialog • net.rim.device.api.ui.Screen Create a class that extends the Manager class. public class newManager extends Manager { In your implementation of the touchEvent(TouchEvent message) method, check if the value TouchEvent.getEvent() returns is equal to TouchEvent.MOVE.
  • Page 42: Keyboard On A Blackberry Device With A Touch Screen

    Keyboard on a BlackBerry device with a touch screen A BlackBerry device application can have more that one Screen. Each Screen has one touch screen keyboard. Change the state of the keyboard on a BlackBerry device with a touch screen Import the following classes: •...
  • Page 43: Hide The Keyboard On A Blackberry Device With A Touch Screen

    Invoke VirtualKeyboard.setVisibility(int) using one of the a new screen. following constants as a parameter: VirtualKeyboard.SHOW or VirtualKeyboard.SHOW_FORCE. Hide the keyboard on a BlackBerry device with a touch screen Import the following classes: • net.rim.device.api.ui.VirtualKeyboard • a screen class, such as net.rim.device.api.ui.container.MainScreen Create an instance of VirtualKeyboard.
  • Page 44: Spell Check

    To notifiy an application when a spell check event occurs, invoke addSpellCheckUIListener() with a SpellCheckUIListener object as a parameter. _spellCheckUI.addSpellCheckUIListener(new SpellCheckUIListener()); To let an application spell check UI fields and suggest spelling corrections to a BlackBerry device user, obtain a SpellCheckEngine object, invoke getSpellCheckEngine(). _spellCheckEngine = _spellCheckUI.getSpellCheckEngine();...
  • Page 45: Listen For A Spell Check Event

    Import the following classes: • java.lang.StringBuffer • net.rim.device.api.ui.UiApplication • net.rim.device.api.ui.Field Import the following interfaces: • net.rim.blackberry.api.spellcheck.SpellCheckUIListener • net.rim.blackberry.api.spellcheck.SpellCheckEngine Create a method that returns the SpellCheckUIListener.LEARNING_ACCEPT constant when the SpellCheckEngine learns a new word. public int wordLearned(SpellCheckUI ui, StringBuffer word) UiApplication.getUiApplication().invokeLater(new popUpRunner("Word learned"));...
  • Page 46 Development Guide Spell check public int misspelledWordFound(SpellCheckUI ui, Field field, int offset, int len) UiApplication.getUiApplication().invokeLater(new popUpRunner("Misspelled word found")); return SpellCheckUIListener.ACTION_OPEN_UI;...
  • Page 47: Storing Data

    Device Software version 4.2 or later provides a traditional file system and support for saving content directly to the file system via JSR 75 APIs. With either the BlackBerry Persistent Store APIs or the MIDP RMS APIs, you can store data persistently to flash memory.
  • Page 48: Persistent Data Storage

    • net.rim.device.api.system.PersistentStore • java.lang.String • net.rim.device.api.ui.component.Dialog To create a unique long key, in the BlackBerry® Integrated Development Environment, type a string value. com.rim.samples.docs.userinfo Right-click the string and click Convert ‘com.rim.samples.docs.userinfo’ to long. Include a comment in your code to indicate the string that you used to generate the unique long key.
  • Page 49: Retrieve Persistent Data

    Import the following classes: • net.rim.device.api.system.PersistentStore • net.rim.device.api.system.PersistentObject To remove all persistent data from a BlackBerry® device application, invoke PersistentStore.destroyPersistentObject(), providing as a parameter a unique key for the PersistentObject. To remove individual data, treat the data as normal objects, and remove references to it. A garbage collection operation...
  • Page 50: Midp Record Storage

    Development Guide MIDP record storage MIDP record storage Create an MIDP record store Import the javax.microedition.rms.RecordStore class. Invoke openRecordStore(), and specify true to indicate that the method should create the record store if the record store does not exist. RecordStore store = RecordStore.openRecordStore("Contacts", true); Add a record to a record store Import the javax.microedition.rms.RecordStore class.
  • Page 51: Collections

    _persist = PersistentStore.getPersistentObject( PERSISTENT_KEY ); Store the returned data in a vector object. _contacts = (Vector)_persist.getContents(); Create a method to provide the BlackBerry device application with the newest SyncCollection data before a wireless data backup session begins. public void beginTransaction() _persist = PersistentStore.getPersistentObject(PERSISTENT_KEY);...
  • Page 52: Create A Collection Listener To Notify The System When A Collection Changes

    • java.util.Vector • net.rim.device.api.collection.CollectionEventSource • net.rim.device.api.collection.CollectionListener • net.rim.device.api.synchronization.SyncCollection Create a private vector object to store the collection of SyncCollection listeners for the BlackBerry device application. private Vector _listeners; _listeners = new CloneableVector(); Implement the CollectionEventSource.addCollectionListener() method, making sure the method adds a CollectionListener to the Vector that contains listeners.
  • Page 53: Notify The System When A Collection Changes

    BlackBerry® devices use a runtime store as a central location in which BlackBerry Java® Applications can share runtime objects. By default, only BlackBerry Java Applications that Research In Motion digitally signs can access data in the runtime store. Contact RIM for information about how to control access to your data.
  • Page 54: Add An Object In The Runtime Store

    Development Guide Runtime storage Add an object in the runtime store Import the following classes: • net.rim.device.api.system.RuntimeStore • java.lang.String • java.lang.IllegalArgumentException Invoke RuntimeStore.put(long, String) and provide as parameters a unique long ID and the runtime object to store. Create a try - catch block to manage the IllegalArgumentException that put() throws if a runtime object with the same ID exists.
  • Page 55: Retrieve An Unregistered Runtime Object

    Runtime storage Invoke RuntimeStore.get() and provide as a parameter the runtime object ID. Create a try - catch block to manage the ControlledAccessException that get() throws if the BlackBerry® Java® Application does not have read access to the specified runtime object.
  • Page 56: Creating Connections

    If your application connects to the Internet rather than to the corporate intranet, you might be able to use the BlackBerry Enterprise Server that belongs to the customer as a gateway. In this case, network requests travel behind the corporate firewall to the BlackBerry Enterprise Server, which makes the network request to the Internet through the corporate firewall.
  • Page 57: Connections

    • javax.microedition.io.StreamConnection Use the CoverageInfo class and CoverageStatusListener interface of the net.rim.device.api.system package to verify that the BlackBerry device is in wireless network coverage area. Invoke Connector.open(), using the HTTP location of the protected resource. Cast and store the returned object as a StreamConnection.
  • Page 58: Use An Https Connection

    Development Guide Connections Create a run()method and within it implement a dialog object to ask the BlackBerry device user for login information. UiApplication.getUiApplication().invokeAndWait(new Runnable()) public void run() dialogResponse = Dialog.ask; (Dialog.D_YES_NO,"Unauthorized Access:\n Do you wish to log in?"); 10. To process the login information, create code to manage a Yes dialog response.
  • Page 59: Use A Socket Connection

    • Specify that an end-to-end HTTPS connection must be used from the BlackBerry device to the target server: EndToEndRequired • Specify that an end-to-end HTTPS connection should be used from the BlackBerry device to the target server. If the BlackBerry device does not support end-to-end TLS, and the BlackBerry device user permits proxy TLS connections, then a proxy connection is used: EndToEndDesired.
  • Page 60: Use A Datagram Connection

    Development Guide Connections • To open a socket connection using BlackBerry MDS Services , append deviceside=false to the end of the URL. BlackBerry device applications must input their local machine IP explicitly because localhost is not supported. private static String URL = "socket://local_machine_IP: 4444;deviceside=false";...
  • Page 61 To send data on the datagram connection, invoke send() on the datagram connection. conn.send(outDatagram); If a BlackBerry®Java® Application attempts to send a datagram on a datagram connection and the recipient is not listening on the specified source port, an IOException is thrown. Make sure that the BlackBerry Java Application implements...
  • Page 62: Use A Usb Or Serial Port Connection

    Using a serial or USB connection, BlackBerry® device applications can communicate with desktop applications when they are connected to a computer using a serial or USB port. This type of connection also lets BlackBerry device applications communicate with a peripheral device that plugs into the serial or USB port.
  • Page 63: Use A Bluetooth Serial Port Connection

    String contents = _din.readUTF(); To close the USB or serial port connection, invoke close() on the input and output streams, and on the port connection object. The close() method can throw IOExceptions. Make sure the BlackBerry device application implements exception handling.
  • Page 64: Wi-Fi Connections

    Wireless access family Description 3GPP includes GPRS, EDGE, UMTS®, GERAN, UTRAN, and GAN CDMA includes CDMA1x and EVDO WLAN includes 802.11™, 802.11a™, 802.11b™, 802.11g™ For more information about wireless access families, see the API reference for the BlackBerry® Java® Development Environment...
  • Page 65: Retrieve The Wireless Access Families That A Blackberry Device Supports

    Development Guide Wi-Fi connections Retrieve the wireless access families that a BlackBerry device supports Import the net.rim.device.api.system.RadioInfo class. Invoke RadioInfo.getSupportedWAFs(). Determine if a BlackBerry device supports multiple wireless access families Import the net.rim.device.api.system.RadioInfo class. Invoke RadioInfo.areWAFsSupported(int wafs). Determine the wireless access family transceivers that are turned on Import the net.rim.device.api.system.RadioInfo class.
  • Page 66: Retrieve The Status Of The Wireless Access Point Or The Active Wi-Fi Profile

    Retrieve the status of the wireless access point or the active Wi-Fi profile You can let a BlackBerry® device application retrieve status information such as the data rate of the connection, the wireless LAN standards used (802.11a™, 802.11b™, or 802.11g™), the SSID of the associated access point, or the name of the Wi-Fi profile in use.
  • Page 67: Open A Wi-Fi Https Connection

    Open a Wi-Fi HTTPS connection The interface=wifi parameter applies only to TCP/UDP connections. To establish a Wi-Fi® connection and use a Wi-Fi API in a BlackBerry® device application, the wireless service provider must support Wi-Fi access. Import the following classes: •...
  • Page 68: Managing Applications

    Managing applications Application manager The BlackBerry® Java® Virtual Machine on the BlackBerry® device includes an application manager that functions as the central dispatcher of operating system events for other BlackBerry device applications. The net.rim.device.api.system.ApplicationManager class lets BlackBerry device applications interact with the application manager to perform the following actions: •...
  • Page 69: Determine The Services That Are Available To A Blackberry Java Application

    BlackBerry device. For example, administrators can use the BlackBerry Application Control IT policy rule to make sure that a game that exists on the BlackBerry device cannot access the phone API. The BlackBerry Application Control IT policy rule works only when the BlackBerry device is connected to a BlackBerry®...
  • Page 70: Code Modules

    For example, you can use PERMISSION_PHONE for an operation that requires access to the phone functionality of the BlackBerry device. You can use the applicationcontrol package to include a custom message with the default message that a BlackBerry device application displays in response to an application control.
  • Page 71: Display An Application Control Message To A User

    ReasonProviders in the order that each ReasonProvider registers with the BlackBerry device application. For example, if a BlackBerry device application registers ReasonProvider A before ReasonProvider B, the BlackBerry device application displays the message from ReasonProvider A, followed by the message from ReasonProvider B.
  • Page 72: Using Custom Messages And Folders In The Message List

    You must determine the functionality that is part of each module. For example, a menu item that lets a BlackBerry device user delete a message or mark a message as read should be part of the daemon module. A menu item that lets a BlackBerry device user open or reply to a message should be part of the UI module.
  • Page 73: Start The Module For Background Processes Or The Module For The Ui

    Start the module for background processes or the module for the UI Import the net.rim.blackberry.api.messagelist.ApplicationMessageFolderRegistry class. Create a main method for the BlackBerry®device application. public static void main( String[] args ) try { In the main() method, check if the value of the args parameter indicates that the BlackBerrydevice application should start the daemon module.
  • Page 74: Create A Custom Folder In The Message List

    MESSAGE_TYPE, STATUS_NEW, newIcon ); reg.registerMessageIcon( MESSAGE_TYPE, STATUS_OPENED, openedIcon ); Create a custom folder in the message list To be able to perform operations on custom messages, the BlackBerry® device application must register at least one custom folder. Import the following classes: •...
  • Page 75: Send A Notification When A Custom Folder Changes

    ); Set the root folder for the folders of the BlackBerry device application. The name of the root folder appears in the View Folder dialog of the Message list application when a BlackBerry device application registers more than one application message folder.
  • Page 76: Create An Indicator For The Number Of Messages In A Custom Folder

    Save a reference to the encoded image in an EncodedImage variable. EncodedImage image = EncodedImage.getEncodedImageResource( "clowds.gif" ); To create an BlackBerry® device application icon based on the encoded image, create an instance of an ApplicationIcon using an EncodedImage as an argument.
  • Page 77 Development Guide Remove an indicator for a custom folder To unregister an indicator, invoke ApplicationIndicatorRegistry.unregister(). reg.unregister...
  • Page 78: Applications For Push Content

    Applications for push content Types of push applications Push applications send web content or data to specific BlackBerry® device users. Users do not need to request or download the data because the push application delivers the information as soon as it becomes available.
  • Page 79 Development Guide Types of push requests Request Supported tasks Push storage • specifying a deliver-before time stamp for the push submission • requesting a result notification of the push submission • specifying a deliver-after time stamp for the push submission PAP push requests are stored in a database.
  • Page 80: Localizing Blackberry Device Applications

    You can use the BlackBerry Integrated Development Environment to compile each resource bundle into a separately compiled .cod file. You can load the appropriate .cod files onto BlackBerry devices with the other .cod files for the application. Resources are organized in a hierarchy based on inheritance. If a string is not defined in a locale, a string from the next closest locale is used.
  • Page 81: Manage Localization Files For A Suite Of Blackberry Device Applications

    Manage localization files for a suite of BlackBerry device applications If you create a suite of BlackBerry® device applications, organize resources into separate projects for each locale. The BlackBerry® Integrated Development Environment provides a built-in initialization mechanism. You only need to create an empty initialization class with an empty main().
  • Page 82 Development Guide Manage localization files for a suite of BlackBerry device applications 14. Add the resource content (.rrc) files to the projects for the appropriate locales.
  • Page 83: Controlling Access To Apis And Application Data

    Locate the item in the API reference for the BlackBerry Java Development Environment. If the item has a lock icon or is noted as ‘signed’ your BlackBerry device application requires a signed key or signature, which RIM provides, before you can load the BlackBerry device application .cod files onto a BlackBerry device.
  • Page 84: Register To Use Controlled Apis

    Click Register. 12. Click Exit. Restrictions on code signatures The BlackBerry® Signing Authority Tool administrator might place restrictions on your .csi file to limit your access to code signatures. To request changes to these restrictions, contact your administrator. .csi file restriction...
  • Page 85: Request A Code Signature

    In Windows® Internet Explorer®, locate the .cod file for the BlackBerry device application for which you are requesting a signature. Make sure that a .csl file with the same name as the .cod file exists in the same folder as the .cod file. The BlackBerry® Integrated Development Environment compiler automatically generates the .csl file.
  • Page 86: Sign An Application Using A Proxy Server

    If you are not an ISV partner, contact your ISV Technical Partnership Manager. If you are a non ISV partner, send an email message to jde@rim.com. At the command prompt, navigate to the BlackBerry® Signature Tool bin directory. For example: C:\Program Files\Research In Motion\BlackBerry JDE 4.6.0\bin Type Java -jar -Dhttp.proxyHost=myproxy.com -Dhttp.proxyPort=80 SignatureTool.jar...
  • Page 87: Protect Apis Using Code Signing Keys

    Protect APIs using code signing keys Protect APIs using code signing keys After you receive an internal key, an external key, or both keys, in the BlackBerry® Integrated Development Environment, open the project that contains the APIs that you want to control access to.
  • Page 88: Protect Persistent Data Using Code Signing Keys

    Store the object in the persistent object and protect the object with the CodeSigningKey object. For example, after a BlackBerry device application runs the following line of code, only code files that are signed with the RSAE .key file can read or overwrite the object in the persistent object.
  • Page 89: Testing A Blackberry Device Application

    Testing applications on a BlackBerry Smartphone Simulator After you develop and compile your application, you can test it on the BlackBerry® device. The most common first step is to set the BlackBerry® Java® Development Environment to use a BlackBerry® Smartphone Simulator. The BlackBerry Smartphone Simulator runs the same Java code as the BlackBerry devices, so the BlackBerry Smartphone Simulator provides an accurate environment for testing how applications will function on a BlackBerry device.
  • Page 90: Install And Remove A .Cod File For Testing

    BlackBerry® Java® Development Environment. For production applications, use the BlackBerry® Desktop Software. You must load BlackBerry device applications with dependencies in the correct order. If project A is dependent on project B, load the project B .cod file before loading the project A .cod file.
  • Page 91 Development Guide Testing applications using the compiled .cod files Open a command prompt and navigate to the location of the JavaLoader.exe file. Perform one of the following actions: Task Steps Retrieve the Name, Version, Size, and Issue a command using the following format: javaloader info Date created information for a .cod .cod file file.
  • Page 92: Packaging And Distributing A Blackberry Java Application

    Wireless pull (user-initiated) You can post compiled applications on a public or private web site. BlackBerry® device users can visit the web site to download the applications over the wireless network by using the browser on their BlackBerry devices. The browser prompts the users to install the application and then the application downloads over the wireless network and installs on the BlackBerry device.
  • Page 93: Modifying Information For A Midlet Suite

    You can use the Updatejad tool, part of the BlackBerry® Java® Development Environment, to process .jad files and perform the following actions: • Correct the .cod file sizes listed in a .jad file. The .cod file sizes listed in the .jad file change after you use the BlackBerry® Signing Authority Tool to sign .cod files. •...
  • Page 94: Correct The .Cod File Sizes Listed In A .Jad File

    Use the BlackBerry® Signing Authority Tool to sign the .cod file. Use the BlackBerry IDE to create two other BlackBerry device application files that use the .jad file, for example, test.cod and test.jad. Use the BlackBerry Signing Authority Tool to sign the new .cod file.
  • Page 95: Distributing Blackberry Device Applications With The Blackberry Desktop Software

    The application element can also contain additional blackBerryVersion nested application elements. Nesting lets you require that, when a BlackBerry device application is loaded on the BlackBerry device, its prerequisite modules are also loaded on the BlackBerry device. The id attribute specifies a unique identifier for the BlackBerry device application.
  • Page 96 The blackBerryVersion attribute specifies the version of the BlackBerry Device Software that a BlackBerry device application requires. files — The files element provides a list of one or more BlackBerry device application .cod files, in a single directory, to load on the BlackBerry device.
  • Page 97 The fileset element includes an optional directory element and one or more files elements. It specifies a set radio of .cod files, in a single directory, to load onto the BlackBerry langid device. To load files from more than one directory, include one or more fileset elements in the .alx file.
  • Page 98 — The hidden element hides a package so that it does not appear to BlackBerry device users in the Application Loader. To hide a package, add the following line: <hidden>true</hidden>. Use this element in conjunction with the required element...
  • Page 99 The requires element is an optional element that specifies the id of a package on which this BlackBerry device application depends. This element can appear more than once, if the BlackBerry device application depends on more than one BlackBerry device application .
  • Page 100: Properties Of Blackberry Device Application .Jad Files

    The BlackBerry® Integrated Development Environment lets you create a dual-purpose .jad file to support the downloading of MIDlets onto BlackBerry devices and other wireless devices. To do this, create a .jad file that contains both the RIM-COD-URL and RIM-COD-Size attributes and the MIDlet-Jar-URL and MIDlet-Jar-Size attributes. On BlackBerry devices, download the .cod files;...
  • Page 101: Application Distribution Through A Computer Connection

    BIN folder in the BlackBerry JDE folder. You can use the JavaLoader tool to quickly install and remove compiled application files on the BlackBerry device directly over the USB port. You do not require any descriptor files or web pages. The JavaLoader tool can be useful when you install and remove your application frequently during testing and development;...
  • Page 102: Install A Blackberry Device Application On A Specific Device

    Open a text editor. Locate the .alx file for the BlackBerry® device application. In the .alx file, make sure the series attribute in the fileset opening tag refers to the BlackBerry device you want to install the BlackBerry device application on.
  • Page 103 _platformVersion attribute. The _platformVersion attribute can be used within the directory tag, the application tag, or the fileset tag. You can use the following rules to specify a version range for the BlackBerry Device Software or the platform version: •...
  • Page 104: Glossary

    Development Guide Glossary Glossary 3GPP Third Generation Partnership Project Advanced Encryption Standard application programming interface access point name CDMA Code Division Multiple Access EDGE Enhanced Data Rates for Global Evolution EVDO Evolution Data Optimized generic access network GERAN GSM-EDGE Radio Access Network GPRS General Packet Radio Service Global System for Mobile communications®...
  • Page 105 Development Guide Glossary MIDP Mobile Information Device Profile Transmission Control Protocol Triple DES Triple Data Encryption Standard User Datagram Protocol UMTS Universal Mobile Telecommunications System UTRAN UMTS Terrestrial Radio Access Network Wireless Application Protocol WLAN wireless local area network...
  • Page 106: Provide Feedback

    Development Guide Provide feedback Provide feedback To provide feedback on this deliverable, visit www.blackberry.com/docsfeedback.
  • Page 107: Legal Notice

    Legal notice Legal notice ©2008 Research In Motion Limited. All rights reserved. BlackBerry®, RIM®, Research In Motion®, SureType®, SurePress™ and related trademarks, names, and logos are the property of Research In Motion Limited and are registered and/or used in the U.S.
  • Page 108 Some airtime service providers might not offer Internet browsing functionality with a subscription to the BlackBerry® Internet Service. Check with your service provider for availability, roaming arrangements, service plans and features. Installation or use of Third Party Products and Services with RIM's products and services may require one or more patent, trademark, copyright, or other licenses in order to avoid infringement or violation of third party rights.
  • Page 109 Development Guide Legal notice The terms of use of any RIM product or service are set out in a separate license or other agreement with RIM applicable thereto. NOTHING IN THIS DOCUMENTATION IS INTENDED TO SUPERSEDE ANY EXPRESS WRITTEN AGREEMENTS OR WARRANTIES PROVIDED BY RIM FOR PORTIONS OF ANY RIM PRODUCT OR SERVICE OTHER THAN THIS DOCUMENTATION.

This manual is also suitable for:

Java development environment

Table of Contents