Developers
Local Navigation
Richard Evers, Editor
Developing software for the BlackBerry® device is an exciting area of development. Although it can be relatively simple, the task can also be daunting depending on your organization's requirements, technical talents, resources and mindset. In this article we will explore the basics of enterprise solutions on the BlackBerry device.
A difficulty many people encounter is in visualizing how to create a useful solution for a wireless device. With desktop-based solutions reigning supreme for so long, it’s often hard to visualize creating something useful for a device with a tiny screen, limited memory, and a relatively slow pipe to the outside world.
As you know, some of the more popular desktop applications are web browsers, email clients, word processors, spell checkers, text editors, calendar tools, spreadsheet applications, presentation tools, document viewers, music players, instant messaging solutions, Customer Relationship Management (CRM) clients and Enterprise Resource Planning (ERP) clients.
Research In Motion® (RIM®) has created several of the core solutions for the BlackBerry device, and third-party developers have created, or are creating, many others. Over time, most desktop functionality will be experienced on the BlackBerry device, with the added bonus of wireless connectivity for features such as email, browser, calendar and phone access, active throughout the world without reliance on power cords or wired network hookups.
Topics within this section include:
- There are three ways to create solutions for BlackBerry
- Accessing a web site using the BlackBerry Browser
- Server-based application that "pushes" content to the BlackBerry device
- Software application on the BlackBerry device and, possibly, also on a remote server
- In closing ...
Three Ways ...
There are three ways to create solutions for BlackBerry devices:
- Create a web site to be accessed using the BlackBerry Browser
- Develop a server-based application that "pushes" content such as a web page and images, or data in general, to the BlackBerry device.
- Write a software application that operates on the BlackBerry device and, possibly, also on a remote server
Accessing a web site using the BlackBerry Browser
This is by far the easiest and fastest solution to put together.
There are several advantages to using the web to extend your existing applications:
- the time to market is faster than developing an application from the ground up
- it is easy to promote software changes
- most organizations have web developing skills in house that are readily available to do this type of work
- communicating with remote databases is fairly straightforward
Although developing web based applications for Blackberry devices can be relatively easy, there are two main drawbacks.
The first is connectivity where users will not be able to access your web site when they are out of a wireless coverage area. This can occur when users are situated in network "dead-zones."
To understand a "dead zone" let's explore how radio waves work.
Radio waves travel easily through air, and fully penetrate transparent materials such as windows, but are absorbed by opaque materials such as concrete, and are reflected by shiny material such as metal.
Network "nodes" must be located fairly close together to allow for uninterrupted connectivity. Nodes may not fully saturate remote regions causing network difficulties when traveling in these regions.
In high-density areas such as major cities, nodes are placed fairly close together to compensate for the increased volume of wireless activity. A network "dead zone" can occur in high-traffic areas if wireless traffic exceeds the capability of the network at any time.
If your users need constant access to your web site, consider writing a "push" application to regularly update each user’s device.
The second drawback is the speed of the wireless network. The networks used by wireless devices, such as the BlackBerry device, are slow compared to traditional wired networks. In order to mitigate this issue, RIM compresses data before transporting across the wireless network. Even then, access speed will be compromised if web pages are large, if they rely heavily on graphic images, if network traffic is heavy, or if network coverage is spotty or weak.
Gateway
It is only possible for a BlackBerry device to access the Internet by making use of a gateway. A gateway works by converting incoming content into a form suitable for the BlackBerry device, and converting outgoing content into a form suitable for the destination web server and site.
There are three gateways available for BlackBerry device:
- Wireless Application Protocol (WAP)
- BlackBerry Mobile Data Service used in conjunction with the BlackBerry Enterprise Server software
- BlackBerry Internet ServiceTM
Gateway: WAP
Wireless service providers usually provide a WAP gateway for their subscribers. The following features are supported by the BlackBerry Browser that operates through a WAP gateway:
Supported image format:
- Wireless Bitmap (WBMP)
Supported web scripting languages:
- Wireless Markup Language (WML)
- WMLScript
Supported server-side scripting languages include:
- Active Server Pages (ASP)
- JavaTM Server Pages (JSP)
- PHP: Hypertext Preprocessor (PHP)
Note: The server must return supported markup language. The device will not process scripting.
Supported server-side languages:
- Anything used to create CGI applications
Supported mobile media:
- None
Security:
-
Wireless Transport Layer Security (WTLS)
Class 1 (encryption only) and Class 2 (encryption and server authentication) - WTLS root certificates
- DES (40 and 56-bit) encryption
- RC5 encryption (64, 128 and 168-bit)
- Does not support the WMLScriptCrypto library
- Protocol is WAP 1.2.2 and WAP 2.0 that features WTLS and Wireless Session Protocol (WSP) header caching
- Sends HTTP over Wireless-Profiled TCP (wTCP) where the request is sent to a WAP 2.0 proxy which forwards it on to the web server
- Supports the Password Authentication Protocol (PAP) which is used for authentication against a remote authentication dial-in user service (RADIUS) for Packet Data Protocol
- Service providers can provision BlackBerry devices wirelessly to enable or disable WTLS support
Other features:
- Supports cookies on the BlackBerry device
- One WAP Push Service record is issued for each bearer that the device is allowed to receive WAP Pushes over. This usually means Short Message Service (SMS) for General Packet Radio Service (GPRS) and Code Division Multiple Access (CDMA) networks, and User Datagram Protocol (UDP) for Integrated Dispatch Enhanced Network (IDENTM) networks.
- Supports the MIDP Over-The-Air (OTA) provisioning standard for wireless application downloads
Gateway:
BlackBerry Mobile Data Service feature
of the BlackBerry Enterprise Server
The BlackBerry Mobile Data Service (MDS) gateway is provided with the BlackBerry Enterprise Server. The following features are supported by the BlackBerry Browser operating through a MDS gateway:
Supported image formats:
- Graphics Interchange Format (GIF)
- Portable Network Graphics (PNG)
- Wireless Bitmap (WBMP)
- Joint Photographic Experts Group (JPEG)
Note: JPEG only supported on color devices
Supported web scripting languages:
- WML
- WMLScript (1.2.1)
- Compact HTML (cHTML)
- XHTML Mobile Profile (XHTML-MP)
- HTML
- JavaScriptTM (version 1.3 and subsets of 1.4 and 1.5)
- Style Sheets (limited support)
Supported server-side scripting languages include:
- ASP
- JSP
- PHP
Supported server-side languages:
- Anything used to create CGI applications
Supported mobile media:
- PlazmicTM PME and PMB formats
- MIDI
Security:
- Protocol HTTP/IPPP
- Secure Socket Layer (SSL) and Transport Layer Security (TLS) to connect to secure HTTP (HTTPS) servers on an intranet or the Internet
- Supports certificate authority authentication to allow connections to untrusted servers or to restrict access to trusted servers only
- Browser content is encrypted between the MDS and the device using Triple DES or AES encryption, transported using the same secure pipeline that is used for email
- Supports three types of network authentication:
- Basic authentication
- NTLM
- Kerberos
Other features:
- The BlackBerry Enterprise Server and BlackBerry Mobile Data Service are typically set up behind the corporate firewall so that data is not encrypted and decrypted over the Internet
- Supports cookies on the BlackBerry device, and maintains them in a cookie cache
- All data transferred from the BlackBerry device to MDS and back is encrypted and compressed for privacy and to help speed up the rate of transmission
- Supports MDS Push:
- Browser Push
- Client/Server Push
- Supports the MIDP Over-The-Air (OTA) provisioning standard for wireless application downloads. Note that MDS will transcode .jar files into .cod format, which allows users to download and install standard MIDlets.
Gateway:
The BlackBerry Internet Service
The BlackBerry Internet Browser was developed to use the BlackBerry Internet Service as a gateway to the Internet. This component is hosted by the BlackBerry infrastructure and is a service offered by certain carriers.
The features provided are similar to those provided through MDS. As an example, both are designed to optimize web content for wireless browsing, and both transcode content types into appropriate formats for display on the device.
The key differences between the BlackBerry Internet Service and MDS are as follows:
- BlackBerry Internet Service does not require BlackBerry Enterprise Server
- BlackBerry Internet Service is not used through a corporate firewall
- BlackBerry Internet Service is made available through selected BlackBerry service providers
- BlackBerry Internet Service does not support Triple DES encryption, and secure sites (HTTPS) are not accessible
BlackBerry Internet Service communicates with the BlackBerry Infrastructure using HTTP over the RIM IP Proxy Protocol (IPPP). Delivery of HTML is both faster and more efficient than HTTP over WAP in most current implementations.
BlackBerry Internet Service was designed to provide the following functionality:
- preprocess and compress HTML or XHTML content before sending it to the BlackBerry device to help speed up transfers
- sends processed content to the device as soon as it is available, rather than sending it only after all data has been completely processed
- optimize images for display on a BlackBerry device
- process and transmit images with content to help reduce network traffic
- transcode specific content types for appropriate display on the BlackBerry device
Server-based application that
"pushes" content to the BlackBerry device
This is a powerful technique used to deliver content directly on BlackBerry devices without user intervention.
A server-side application is created to send content to one or more BlackBerry devices through MDS and the BlackBerry Enterprise Server. There are four push techniques available:
- Message List
- A link to the URL is stored as an email message.
- Browser Cache
- Stores the data directly in the BlackBerry Browser’s cache so that the BlackBerry Browser uses the cached data rather than making a wireless transfer.
- Channel Push
- Places an icon entry point on the BlackBerry device's home screen. When selected, the icon will change state (optional) and then calls the browser to load a cached page.
- Data Push
- Transmitted to the BlackBerry device with the expectation that a custom listener, as opposed to the browser, has been set up to accept the pushed data.
Advantages include:
- can be written in most server-side languages
- the push process is controlled from the server side
- push applications are relatively easy to write
- each push request is designed to refresh the currently cached copy when network coverage permits
Disadvantage:
- data format is limited to what the BlackBerry Browser can handle or what a custom developed application can decode
Software application on the BlackBerry device
and, possibly, also on a remote server
Custom software development is the most versatile way to create a solution for BlackBerry devices. All Java-based BlackBerry devices are programmed in Java 2 Micro Edition (JavaTM ME) using the BlackBerry Java Development Environment (JDE), or your favorite Java ME kit.
The main advantage of developing a custom application for BlackBerry is that you have control over features, functionality, look, feel, network handling and access to server-side applications. Device applications written in Java can also be deployed for Over-The-Air (OTA) installation.
Although these solutions can be more robust, they do require development staff with Java ME experience, time and associated resources to see the entire process through to completion.
Sun MicrosystemsTM has defined configurations and profiles within Java ME that include Connected Limited Device Configuration (CLDC) and Mobile Information Device Profile (MIDP):
- CLDC defines an underlying environment based on the physical capabilities of the device
- MIDP determines the core application functionality on the device
Java ME is a configuration (CLDC) and a profile (MIDP) that is specific to devices that share the following characteristics:
- a minimum of 128kb to 512kb of memory, with a 16- or 32-bit CPU
- it must provide an implementation of a small Virtual Machine (VM)
- is battery operated, with a low-level of power consumption
- it has wireless network connectivity and restricted bandwidth
Java ME does not provide support for the following Java 2 Standard Edition (J2SE) features:
- floating point operations
- Java Native Interface (JNI)
- large user interface APIs such as Swing and AWT
- thread groups
- Daemon threads
- finalization
- Object serialization
- reflection
- Remote Method Invocation (RMI)
Java ME is limited to three error classes, restricts file handling to Record Management System (RMS) persistent storage, and does not provide a class loader.
The latest release of the BlackBerry Handheld Software version 4.0 and JDE support MIDP 2.0. This release has been greatly improved from previous MIDP releases in the following areas:
- Security
- Network connectivity
- Push registration
- Audio
- Gaming
- Over-The-Air provisioning
The BlackBerry API
Often a key component in developing applications that take advantage of BlackBerry device functionality is to use the BlackBerry series of APIs. The following are many of the APIs that are included in the latest 4.0 release of the BlackBerry Java Development Environment:
- Application Invocation
- Allows third-party applications to remotely invoke BlackBerry applications
- Bluetooth®
- Provides serial communication support for Bluetooth connections
- Browser
- Provides access to the BlackBerry Browser application to create and display HTML or WML pages and to set browser options
- Browser Field
- Provides access to browser-component functionality to integrate in applications
- Browser Plug-in
- Defines the Plugin API used to add support for specific MIME-types to the BlackBerry Browser
- Collection
- Defines basic functionality for data collections
- Compress
- Provides components for compressing and decompressing data.
- Crypto
- A collection of classes used to implement security for BlackBerry applications. The following tasks can be accomplished with the Crypto API:
- encrypt and decrypt data
- digitally sign and verify data (secure the integrity of your data)
- authenticate data
- A collection of classes used to implement security for BlackBerry applications. The following tasks can be accomplished with the Crypto API:
- Internationalization
- To support internationalization of applications
- IO
- A library of components to manage data input/output
- IT Policy
- Used to customize features that are common to all users on a given BlackBerry Enterprise Server, such as password details, mail forwarding options and browser settings. IT policies provide an efficient method to manage many different users simultaneously.
- Lightweight Data Access Protocol (LDAP)
- LDAP is a client-server protocol used for accessing directories. It allows you to access and browse through information on remote directory servers.
- Low Memory
- Maintains memory resources on the device when the device becomes over-taxed and runs low on memory
- Mail
- Functionality for sending, receiving and accessing email and PIN messages
- Math
- A collection of fixed-point math routines, and implementations of a stack for use in matrix multiplication
- Menu Item
- Used to add custom menu items to applications
- MIME
- For manipulating streams of MIME encoded data
- Notification
- Functionality to trigger event notifications through Consequence (tone, vibration or LED) or NotificationsEngineListener (dialogs or interaction screens on the device)
- Options
- Used to add items to the device's Options screen
- PDAP
- Interfaces that developers should implement to conform to the Personal Digital Assistant Profile (PDAP) specification on the BlackBerry device (such as Address Book contacts and Calendar entries). Also see the PIM package from the MIDP specifications.
- Phone
- Provides access to the BlackBerry Phone application to initiate calls, receive related notification events, and change phone options
- Plazmic Media Engine
- Contains necessary functionality to allow media on the BlackBerry device to be downloaded and viewed.
- Service Book
- Used to store setup and configuration information on a BlackBerry device, and contains ServiceRecords that define information about BlackBerry connections. Service records are used to manage the BlackBerry device's CMIME (mail) and IPPP (Internet connections) and are also valuable for keeping track of network UIDs to more easily manage MDS connections.
- Synchronization
- Provides functionality required to synchronize data between the BlackBerry device and the BlackBerry Desktop Software, and contains classes and methods used to provide backup and restore functionality to applications
- System
- A variety of system-level functionality such as:
- interfaces classes that can be implemented to listen for various system level events
- base classes for application functionality, and application management
- base classes to describe persistable data objects, and stores of such objects
- system-level access to BlackBetrry device services such as the radio, phone, peripherals, available networks, event logger, memory manager, serial port, speaker, SIM card and more
- A variety of system-level functionality such as:
- User Interface
- Functionality for constructing a user interface
- XML
- SAX and WBXML parsers
The BlackBerry JDE
The BlackBerry Java Development Environment (JDE) is comprised of a series of development tools used to test and create applications for BlackBerry.
The full environment consists of a Java ME compiler, editor, debugger, profiler, BlackBerry device simulator, BlackBerry Mobile Data Service (MDS) simulator and an email server simulator. The BlackBerry JDE was designed to use any source control system that has a command line. Note that the device simulator can also be used to test commercial applications before corporate deployment.
JDE Compiler
The compiler has been designed to generate small destination files for wireless deployment. The contents of each .cod file are optimized for byte code and then obfuscated. During creation, images are also converted into .png format. Compiled files can be deployed directly through the BlackBerry Desktop Manager, or deployed Over-The-Air on a web site, or "pushed" to corporate devices with BlackBerry Enterprise Server 4.0.
Note that .cod files must be compiled for specific ranges of BlackBerry device OS revisions. The latest compiler must be used for devices that are running BlackBerry Handheld Software version 3.8 or later. Earlier versions use .cod files compiled with JDE versions prior to version 4.0.
Editor
The editing environment is similar to most GUI editors with the exception that you can directly set and deselect breakpoints and symbolic bookmarks, auto-complete methods, show class definitions, and display methods in outline and packages.
The Debugger
The debugging stage is always the most difficult portion of the development cycle. Where the physical act of writing software can be a wonderful experience, debugging can be the worst. The transition from lower-level languages such as assembler and C, to higher-level languages such as C++ and Java, has made it easier to create software solutions, but more difficult to debug them. This is often due to the increased complexity of working in an event-driven environment that relies heavily on externally developed components. The BlackBerry JDE comes with a debugger that will ease debugging pain greatly.
Two debugging techniques can be used.
The first is to set a few breakpoints at critical sections of your code, and then gradually set breakpoints at shorter intervals to identify the source of the problem. Select Go from the Debug menu to compile and run all active applications in the simulated environment. After the program has paused at a breakpoint, use debugging tools to view various application processes and statistics to identify the problem.
The second technique is to start a debugging session with the BlackBerry device simulator, then click Break Now on the Debug menu in the main window. The breakpoints pane will display the section of code and the line number at which the program is paused. The edit pane will display the source code, with an arrow to indicate the line of code at which the application is paused. And the output pane will display messages from the debugger
To resume debugging after pausing at a breakpoint, click Continue on the Debug menu. To stop the debugging session in the simulator, click Quit on the File menu.
The memory statistics tool that becomes available during debugging sessions can be used to find memory leaks.
Note that debugging can also be performed on a live Blackberry device connected to the computer through the serial or USB connections.
Profiler
The Profiler tool shows the percentage of time spent in each code area to the current point of execution. You can use it to profile efficiency of code sections by setting a breakpoint at the start and end of the section of code that you want to profile, start a debugging session with the simulator, run until the first breakpoint is reached, then click Profile on the View menu. Click Options in the profile plane, set the profile options, then click Go to continue running the application. When the second breakpoint is reached, click Profile on the View menu, then click Refresh to retrieve accumulated profile data from the Java Virtual Machine (JVMTM). Use profile views to display information about the section of code that you just ran.
The Summary view shows general statistics about the system and garbage collector.
The Methods view shows a list of modules, sorted either by the information that you are profiling or by the number of times each item has been executed.
The Source view shows the source lines of a single method. You can navigate through the methods that call, and are called by, that method.
BlackBerry Device Simulator
The BlackBerry device simulator is designed to function similar to an actual BlackBerry device, and displays icons on the Home screen for all applications that have been loaded.
The BlackBerry device simulator should start automatically when you run programs in the IDE. If it does not, select the Launch simulator check box in simulator preferences.
If you are testing applications that require an HTTP connection, you must also start the BlackBerry Mobile Data Service simulator. In the IDE simulator preferences, select Launch Mobile Data Services (MDS) with simulator, or start the MDS Simulator manually.
Start the simulator by clicking on Go on the Debug menu.
BlackBerry Mobile Data Service Simulator
The BlackBerry Mobile Data Service Simulator is designed to provide a full simulation of the Mobile Data Service so that you can test client/server applications with your device simulator and MDS simulator.
Email Server Simulator
The email simulator allows you to transmit and receive mail using the BlackBerry device simulator and a local mail client or remote mail server. It supports POP3 and SMTP.
Take the time to learn more about BlackBerry development by reviewing resources provided by Research In Motion (such as webcasts, case studies and more), review articles publishing in the BlackBerry Developer Journal and work with the BlackBerry JDE to see what you can create. It truly is less hard than it looks to create world-class software for BlackBerry.
In closing ...
Wireless development is still in its infancy relative to development in the wired world. With the right approach, this may directly translate into countless opportunities to excel within your industry and can provide your company with a competitive advantage.
Please email your comments, suggestions and editorial submissions to