 | Level: Intermediate Frank Ableson, Author
19 Aug 2008 There is perhaps no bigger market-transformational technology than the cell
phone. And within that classification of devices, perhaps none more recognizable than
the BlackBerry from Research In Motion (RIM). Most people think it is just for business
e-mail, but there is untapped potential in that addictive device. Despite being a
popular platform, third-party applications are still needed for the BlackBerry
platform. There is no better way to bring those applications to fruition than to
enable the help from the open source community. Follow along as this tutorial lays the
groundwork for an open source data-collection application, upon which an accessible and
easy-to-use data-collection service is built.
Before you start
This tutorial is for open source and Java™ technology developers
interested in BlackBerry application development in the context of a mobile
data-collection application. The example application demonstrates a simple
data-collection application leveraging the freely available BlackBerry development
tools. Mobile development experience is helpful, but not required. Java programming
skills are required for BlackBerry applications, but are not an explicit requirement for
this tutorial. Likewise, PHP and MySQL are employed on the back end, so familiarity
with those platforms is helpful, but, again, not a requirement.
About this tutorial
So why are we concerned about writing applications for BlackBerry? One of the
challenges of open source software is that it is often seen with only a single face
— Linux® — and that is often hidden on a server buried in a
data center. However, one of the biggest secrets in the market is that the most popular
and powerful mobile platform uses an open source programming language: the Java
programming language. That's right, an open source language powers the applications in
the BlackBerry devices used every day.
BlackBerry applications represent an interesting convergence of usage profile and
capability. The prototypical user of a BlackBerry is a professional who uses a
BlackBerry for work. BlackBerry devices allow people to be more available and
real-time because BlackBerry is the current leader in mobile e-mail use. But the
BlackBerry platform offers more than just e-mail. Built upon a J2ME foundation, RIM
has extended the Java environment to provide powerful and desirable features enabling
useful and fun applications for business and entertainment alike. As new mobile
platforms come on the scene, the measuring stick is BlackBerry. If other platforms
compare themselves to BlackBerry, there is motivation enough to explore the capabilities of this market-moving platform.
This tutorial introduces BlackBerry application development within the context of the
mobile data-collection application space. It provides an introduction to BlackBerry
development with a quick introduction to the platform, a tour of the BlackBerry
development tools, and construction of a complete data-collection application.
Complete source code is available for the BlackBerry application and the server-side
components used in the sample application in the Download
section. This tutorial is organized into the following sections:
- BlackBerry platform basics
- BlackBerry application development with JDE
- Data-collection applications with BlackBerry
- Transaction processing on the server side
- Next steps
System requirements
This tutorial demonstrates a few open source technologies and stitches them together to
form a prototype for an open source mobile data-collection platform. You need all of
them to perform the steps in this tutorial. Our primary focus is developing
applications for the BlackBerry platform, so those pieces are the primary requirement.
You can leverage a publicly available Web site for server-side transactions if building
out the server side is not of interest to you. Here's the full list:
- BlackBerry Java Development Environment
- This tutorial employs V4.0.2 of the JDE, although a later version is available.
- PHP
- PHP may be downloaded from PHP.net. The latest stable release is V4.4.9.
- MySQL
- The latest stable release is V5.0.
- IBM Tutorial on BlackBerry Data Collection Applications
- Access the author's site hosting the server-side transactions.
Sample code highlights
In this tutorial, a generic data-collection application is constructed for the
BlackBerry. It has the uninspiring name of bb_ibm_demo. But don't let the name fool
you. When the concepts presented are absorbed, a whole host of useful applications
await. Full source code is available in the Download
section. Source-code snippets include:
- bb_ibm_demo constructor
- This is the primary class of the BlackBerry application.
main() method in bb_ibm_demo of the BlackBerry application
- This is the public static void method for the application (the entry point of the
BlackBerry application).
- bb_ibm_screen constructor
- This is the actual user interface (UI) shown to the user on the BlackBerry. This method
demonstrates the creation of the UI elements.
fieldChanged()
- This is the method that handles button presses in the UI screen on the BlackBerry.
ProcessTransaction
- This method communicates from the BlackBerry to a server over the Internet using HTTP.
- index.php
- This is the home page of our sample server application. From here, you can launch a
search for previously uploaded transactions.
- db.php
- Manages connection to MySQL database.
- export.php
- Provides an export to CSV file of uploaded transactions.
- manage.php
- Manages uploaded transactions. Add to this file for your own functionality.
- showtransactions.php
- Displays any transactions loaded for a specific identifier.
- posttransaction.php
- This server routine works hand in hand with ProcessTransaction on the BlackBerry to record data collected in the field.
- utils.php
- This file contains helper functions for managing transactions on the server.
- db.sql
- This script contains the data-definition language (DDL) to create the transaction table used on the server.
|  |