Blackberry JAVA DEVELOPMENT ENVIRONMENT - - FUNDAMENTALS GUIDE Fundamentals
Blackberry JAVA DEVELOPMENT ENVIRONMENT - - FUNDAMENTALS GUIDE Fundamentals

Blackberry JAVA DEVELOPMENT ENVIRONMENT - - FUNDAMENTALS GUIDE Fundamentals

Table of Contents

Advertisement

Quick Links

BlackBerry Java Development Environment
Version: 4.7.0
Fundamentals Guide

Advertisement

Table of Contents
loading

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

  • Page 1 BlackBerry Java Development Environment Version: 4.7.0 Fundamentals Guide...
  • Page 2 SWDT499912-499912-1212115921-001...
  • Page 3: Table Of Contents

    API control and code signing................................ Object modeling....................................Multithreading....................................Best practice: Using multithreading............................ Best practices for writing an efficient BlackBerry Java Application..................Best practice: Writing efficient code............................ Best practice: Using objects judiciously..........................Best practice: Reducing the size of compiled code......................Multilanguage support...................................
  • Page 4 BlackBerry device user input and navigation..........................Trackwheel versus Trackball..............................Creating a UI that is consistent with standard BlackBerry UIs....................4 Memory management................................. Managing memory..................................BlackBerry device memory..............................Key resources to reserve................................ Best practice: Minimizing memory use..........................Managing low memory availability...............................
  • Page 5 Application control..................................File encryption on microSD cards..............................Encryption of data on a microSD media card........................Using the microSD media card with more than one BlackBerry device................IT policies and the microSD media card..........................9 Test a BlackBerry Java Application............................Obfuscating a BlackBerry Java Application..........................
  • Page 6 10 Making applications available..............................Application distribution through a computer connection......................Distribute an application from a computer......................... Distribute an application from a web page......................... Distribute an application for testing............................ Application distribution over the wireless network........................Wireless pull (user-initiated)..............................Wireless push (server-initiated)............................11 Glossary......................................
  • Page 7: Understanding Blackberry And Programming For Blackberry Devices

    For example, a CRM system can provide a massive amount of information, but users only require a small amount of that information at one time. The BlackBerry device UI is designed so that users can perform tasks easily and access information quickly.
  • Page 8: Release Cycles And Versions

    All BlackBerry® devices include a specific version of the BlackBerry® Device Software and the BlackBerry® Java® Virtual Machine. To determine the version of the BlackBerry Device Software for a BlackBerry device, in the device Options, click About. You can upgrade the BlackBerry Device Software. For example, you can upgrade a BlackBerry device with BlackBerry Device Software version 4.0 to BlackBerry Device Software version 4.1.
  • Page 9: Java Me And Java Apis For Blackberry

    RAPC: You can use this command prompt compiler to compile .java and .jar files into .cod files that you can run in the BlackBerry Smartphone Simulator or on a BlackBerry device. • JavaLoader: You can use this tool to add or update an application on a BlackBerry device for testing, and to view information about application .cod files. •...
  • Page 10: Support For Java Api Extensions

    JSR 238: Mobile Internationalization API Support for Java API extensions BlackBerry® devices support the following Java® APIs that are not part of the standard JSR definitions and that can provide greater features and functionality over what is available in the standard MIDP API libraries.
  • Page 11: Blackberry Enterprise Solution

    BlackBerry® device users who are not associated with a BlackBerry® Enterprise Server can use the BlackBerry® Internet Service. The BlackBerry Internet Service is an email and Internet service for BlackBerry devices that is designed to provide users with automatic delivery of email messages, wireless access to email attachments, and access to Internet content.
  • Page 12: Blackberry Java Application Design

    Standalone applications You can use the BlackBerry® APIs to build standalone applications, such as games and static reference guides that can run as offline applications. You can add the required resource data to an application before you compile it. BlackBerry device users can install the application over the wireless network or with the BlackBerry®...
  • Page 13: Cldc Applications

    UiApplication class and starts with a standard main() method. Most of the sample applications that the BlackBerry® Java® Development Environmentincludes use the CLDC application model. All of the core BlackBerry applications (including message list, contacts list, calendar, and the browser) are built as CLDC applications.
  • Page 14: Api Control And Code Signing

    Public APIs are either open or signed. Signed APIs expose the methods to access BlackBerry device user data or other information on the BlackBerry device that is considered sensitive. You can use signed APIs, but you must request and receive a set of code signing keys from Research In Motion.
  • Page 15: Best Practices For Writing An Efficient Blackberry Java Application

    Best practices for writing an efficient BlackBerry Java Application Best practices for writing an efficient BlackBerry Java Application Best practice: Writing efficient code To allow a BlackBerry® Java® Application to use resources efficiently, consider the following guidelines: • Use local variables.
  • Page 16 .cod file as final. Using int instead of long In Java®, a long is a 64-bit integer. Because BlackBerry® devices use a 32-bit processor, operations can run two to four times faster if you use an int instead of a long.
  • Page 17 Optimizing division operations Division operations can be slow on BlackBerry® devices because the processor does not have a hardware divide instruction. When your code divides a positive number by two, use shift right by one (>> 1). Use the shift right (>>) only when you know that you are working with a positive value.
  • Page 18 Fundamentals Guide Best practices for writing an efficient BlackBerry Java Application Avoiding java.util.Enumeration Avoid using java.util.Enumeration objects unless you want to hide data (in other words, to return an enumeration of the data instead of the data itself). Asking a vector or hash table for an Enumeration object is slow and creates unnecessary garbage.
  • Page 19 Fundamentals Guide Best practices for writing an efficient BlackBerry Java Application Avoiding StringBuffer.append (StringBuffer) To append a String buffer to another, a BlackBerry® Java Application should use net.rim.device.api.util.StringUtilities.append ( StringBuffer dst, StringBuffer src[, int offset, int length ] ). Code sample...
  • Page 20: Best Practice: Using Objects Judiciously

    For identifiers to remain unique across a BlackBerry® Java Application, use keys that an application generates based on a hash of a String. In the input String, include enough information to make the identifier unique. For example, use a fully qualified package name such as com.rim.samples.docs.helloworld.
  • Page 21 Fundamentals Guide Best practices for writing an efficient BlackBerry Java Application • Set appropriate access. • Avoid creating interfaces. • Use static inner classes. • Avoid unnecessary field initialization. • Import individual classes. Setting appropriate access When you create code libraries, you can significantly reduce the size of your compiled code by using the appropriate access modifiers for fields and methods.
  • Page 22: Multilanguage Support

    Field _fieldWithFocus; private boolean _validLayout; private boolean _validLayout; Importing individual classes A BlackBerry® Java Application that uses only a small number of classes from a package should only import the individual classes. Code sample import net.rim.blackberry.api.browser.Browser; Multilanguage support The BlackBerry® Integrated Development Environment includes a resource mechanism for creating string resources. The Localization API is part of the net.rim.device.api.i18n package.
  • Page 23: Multimedia Support

    Multimedia support Audio support You can create a BlackBerry® Java Application that works with the audio formats that a BlackBerry device supports. The type of audio format that a BlackBerry device supports depends on the BlackBerry device model number. For more information about audio support on a BlackBerry device, visit www.blackberry.com/developers.
  • Page 24: Ui And Navigation Design

    BlackBerry® devices include a keyboard, a trackwheel or trackball, and an Escape key, for input and navigation. The Escape key provides an easy way for BlackBerry device users to go back to the previous screen or remove a menu or dialog box from the screen.
  • Page 25: Creating A Ui That Is Consistent With Standard Blackberry Uis

    You can use standard MIDP APIs and BlackBerry® UI APIs to create BlackBerry® Java Application UIs. The BlackBerry UI APIs are a library of UI components that are designed to provide default layouts and behaviors that are consistent with the core BlackBerry device applications.
  • Page 26: Memory Management

    BlackBerry Java Application. Key resources to reserve • Flash memory: The persistent storage space that is available on the BlackBerry® device is a fixed amount of flash memory, typically in the range of 8 MB to 64 MB. • Persistent object handles: The handles that are assigned to each persistent object are consumed only by persistent objects.
  • Page 27: Best Practice: Minimizing Memory Use

    Reuse objects as much as possible. • Move heavy processing to the server. For example, you can filter or sort data before sending it to the BlackBerry® device. Managing low memory availability The low memory manager handles memory resources on the BlackBerry® device when the available memory resources fall below a certain threshold.
  • Page 28: Best Practice: Consolidating Objects Into Object Groups

    One of the most common errors that application developers encounter is an exhaustion of persistent object handles. The amount of flash memory on the BlackBerry® device determines the fixed number of persistent object handles that are available in the system. Depending on the data structure selection, stored records can quickly exhaust the number of persistent object handles.
  • Page 29: Garbage Collection On A Blackberry Device

    Idle garbage collection on a BlackBerry device Garbage collection does not occur every time that the BlackBerry® device idles. It occurs only when the system considers a garbage collection operation to be beneficial for optimal system performance and maximized battery performance.
  • Page 30: Data Management

    The File Connection APIs provide a traditional file system, and support for saving data directly to the file system on the BlackBerry® device or to a microSD card. You can view data in the file system and move the data to a computer by using...
  • Page 31: Storage On Removable Media

    Backing up and synchronizing data The BlackBerry® Desktop Manager provides a backup and restore tool that a BlackBerry device user can use to save BlackBerry device data to a file on a computer and to restore data to the BlackBerry device.
  • Page 32 BlackBerry Desktop Manager add-in, which notifies the application on the BlackBerry device to send the data to the computer application. You can also write data to the computer application using the native USB protocols.
  • Page 33: Wireless Data Transport

    Internet or to the corporate intranet. You can design your application to rely on the default gateway that is available to the BlackBerry device user, or you can customize your code to choose a preferred gateway.
  • Page 34: Alternative Data Transport Options

    PIN messaging uses the data channel rather than the voice channel and allows you to address the destination BlackBerry® device by its unique PIN number. PIN messaging can only be used to send data from one BlackBerry device to another. The BlackBerry APIs can also allow an application to programmatically send and receive BlackBerry PIN messages.
  • Page 35: Blackberry Application Integration

    Adding custom menu items A BlackBerry® Java® Application can add custom menu items to the menu on the BlackBerry device for the email, organizer, and phone applications. When a BlackBerry device user selects the custom menu item, theBlackBerry Java Application starts with a reference to the object that the BlackBerry device user selects.
  • Page 36: Using Listeners To Respond To Application Changes

    The listeners allow the BlackBerry Java Application to take immediate action when the BlackBerry device user performs a local event. You can use the email and organizer data listeners to notify a BlackBerry Java Application when new entries arrive or when the BlackBerry device user makes changes such as additions, deletions, or updates, to the existing data.
  • Page 37: Security Considerations

    If your application uses the BlackBerry® Internet Service or the Internet gateway of the wireless service provider, data traffic is not encrypted. If your BlackBerry device users prefer, you can use HTTPS to encrypt the data, or you can use the Java® APIs for encryption to apply your own symmetric key or public key cryptography.
  • Page 38: Authentication

    For applications where security features are critical, you might want to provide a login screen that requires the BlackBerry® device user to log into the application on the BlackBerry device before using it. The UI classes provide simple password fields that hide the text entry with asterisk characters.
  • Page 39: Blackberry Apis With Controlled Access

    To test and debug your code before you receive the code signatures, you can use the BlackBerry® Smartphone Simulator. You must sign the application before you install it on BlackBerry devices. You do not send your actual code to RIM. You can use the BlackBerry®...
  • Page 40: It Policy Support

    Encrypted files have a .rem extension and cannot be decrypted on non-BlackBerry platforms. If the NVRAM is removed and the microSD media card is locked with a BlackBerry device key, the data on the microSD media card is no longer accessible.
  • Page 41: Using The Microsd Media Card With More Than One Blackberry Device

    Using the microSD media card with more than one BlackBerry device If the BlackBerry® device user moves the microSD media card to a BlackBerry device that does not use a device password or uses a password that does not successfully decrypt the microSD media card master key, the BlackBerry device prompts the BlackBerry device user to enter the microSD media card password.
  • Page 42: Test A Blackberry Java 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 43: Testing Applications On A Blackberry Device

    For debugging purposes, you can attach your device to the BlackBerry® Integrated Development Environment and use the debugging tool to step through your application code. The BlackBerry IDE can be useful if you are trying to identify a network or Bluetooth®...
  • Page 44: Blackberry Email Simulator

    The BlackBerry® Email Simulator is designed to send and receive messages between the BlackBerry® Smartphone Simulator and either a messaging application, such as Microsoft® Outlook®, or POP3 and SMTP servers. You do not require a BlackBerry® Enterprise Server. To get the BlackBerry Email Simulator, visit www.blackberry.com/developers...
  • Page 45: Making Applications Available

    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 46: Wireless Pull (User-Initiated)

    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 47: Glossary

    Fundamentals Guide Glossary Glossary Advanced Encryption Standard application programming interface CLDC Connected Limited Device Configuration HTTP Hypertext Transfer Protocol HTTPS Hypertext Transfer Protocol over Secure Sockets Layer input/output IMAP Internet Message Access Protocol interprocess communication JDWP Java® Debug Wire Protocol Java®...
  • Page 48 Fundamentals Guide Glossary PDAP PDA Optional Packages for the J2ME Platform personal information management personal identification number Post Office Protocol RAPC RIM Application Program Compiler Record Management System Secure Hash Algorithm Short Message Service SMTP Simple Mail Transfer Protocol SRAM static random access memory Secure Sockets Layer Transmission Control Protocol...
  • Page 49 Fundamentals Guide Glossary Wireless Application Protocol Extensible Markup Language...
  • Page 50: 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 51 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 52 Fundamentals 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 4.7.0

Table of Contents