Book Image

BlackBerry Java Application Development

Book Image

BlackBerry Java Application Development

Overview of this book

BlackBerry Smartphone was once the domain of jet-setting business users with power suits. Now you can hardly go anywhere without seeing someone using a BlackBerry to check their messages or make a call. It's this kind of explosive growth that makes the BlackBerry ecosystem a great place to develop and market applications through the BlackBerry App World store—this book shows you how to do just that! This step-by-step guide gives you a hands-on experience of developing innovative Java applications for your BlackBerry. With the help of this book, you will learn to build your own applications to illustrate the platform, and the various capabilities that developers can use in their programs. It explores the powers of Blackberry and helps you develop professional and impressive Java applications. The book teaches how to write rich, interactive, and smart BlackBerry applications in Java. It expects the readers to know Java but not Java Mobile or the BlackBerry APIs. We will learn to build rich, interactive, and smart Java applications for the BlackBerry. The book will cover UI programming, data storage, programming network, and internet API apps. As we move on, we will learn more about the BlackBerry's device features, such as messaging, GPS, multimedia, contacts and calendar, and so on.This book also helps you build your own applications to illustrate the platform, and the various capabilities that developers can use in their programs.
Table of Contents (18 chapters)
BlackBerry Java Application Development
Credits
About the Author
Acknowledgement
About the Reviewers
Preface

Preface

The book teaches how to write rich, interactive, and smart BlackBerry applications in Java. It expects the readers to know Java but not Java Mobile or the BlackBerry APIs. This book will cover UI programming, data storage, programming network, and Internet API apps. As we move on, you will learn more about the BlackBerry’s device features, such as messaging, GPS, multimedia, contacts and calendar, and so on. This book also helps you build your own applications to illustrate the platform and the various capabilities that developers can use in their programs.

What this book covers

Chapter 1, Introducing BlackBerry Application Development gets you started by talking about the capabilities of a BlackBerry smartphone and what kind of things can be done with these capabilities with a custom application. It talks about the other tools which are available and why writing native Java applications by using the BlackBerry SDK is the most powerful and practical approach to developing applications. Finally, it covers how to select which version of the SDK to use and when you might want to use an older version of the SDK instead of the latest.

Chapter 2, Installing the development Environment steps you through the process of installing the proper versions of Java and Eclipse. This chapter talks about when to install additional versions of the SDK and how to do so through the Eclipse over-the-air update tool as well as how to install them manually.

Chapter 3, Getting Familiar with the Development Environment starts off the learning process by importing an existing sample application—the standard "Hello World" application. After importing the project, the chapter will go over this simple application line-by-line. Afterwards, you will run the application in the simulator and then introduce a bug into the application so that you can debug it as well.

Chapter 4, Creating your first BlackBerry Project is where you create a new project from scratch. This chapter demonstrates how you accomplish this using Eclipse and the various wizards that are available within it. It also demonstrates how you can create a simple, but complete application quickly using the User Interface (UI) elements provided by the framework.

Chapter 5, Learning the Basics about the UI creates an application to demonstrate each of the UI elements that are available to you when using the BlackBerry SDK. This sample application demonstrates how to set and retrieve data from each field and discusses when each field should be used according to the BlackBerry development guidelines. By demonstrating each field, you will get a complete understanding of the capabilities of each field.

Chapter 6, Going Deeper into the UI picks up where the previous chapter leaves off by demonstrating how to use some of the advanced fields, such as lists and trees. It also covers navigation between screens, displaying dialogs, and common patterns used in the BlackBerry SDK. By the time you are done with this chapter, you will be well equipped to create the entire UI for an application.

Chapter 7, Storing Data jumps right into how to use the data storage tools of the SDK and when it is appropriate to use each one. This covers the Java standard RMS, the BlackBerry-specific PersistentStore, and even how to access the removable media cards that are available on some devices.

Chapter 8, Interfacing with Applications shows you how to take advantage of one of most powerful features available to a BlackBerry application. Each BlackBerry device comes with standard applications that you can interface with. These include the address book, calendar, and even the messaging applications. Being able to tightly integrate an application with these can make it even more valuable and useful to the end user.

Chapter 9, Networking wades into the complex, but an important area of how to make an application networking aware. Here, you will discover what transports are available, how to open connections , and how to send data through them. The sample also demonstrates how to communicate with a simple web service and parse the resulting XML data.

Chapter 10, Advanced Topics covers two distinct, but powerful topics. The first topic is how to utilize the built-in GPS receiver that is built in to some smartphones in order to get location information. You will learn about the various methods that can be used to get location information and how to do some common calculations using these coordinates. The other topic covered in this chapter covers how to use alternate entry points so that a single project can be used to launch multiple applications. Because these applications share a common project, they can share code and even memory.

Chapter 11, Wrapping It All Up finishes the book with tasks that commonly are done last, such as localization with language resource files and code-signing your application so that it can be installed on real devices. You will also learn what it takes to distribute your new application through the BlackBerry App World marketplace.

What you need for this book

In order to get started you don’t need anything at all except some starter code, which is available with the code bundle of this book. Everything else that you will need will be downloaded and installed through the course of this book, mostly in Chapter 2. In this chapter, we will install the Java 2 JRE (Java Runtime Environment) and JDE (Java Development Environment), which are both needed to run Eclipse, the development environment, and to compile the applications you will be making. Eclipse comes in several versions from www.eclipse.org, but we will be using a version from RIM, which has been pre-bundled with the BlackBerry SDK.

Beyond the software needs you will also need experience with an object-oriented development language such a Java, C#, or even C++. You should be familiar with common object-oriented terms such as classes, members, inheritance, and even interfaces. Furthermore, you should understand common concepts such as threading and serialization.

Who this book is for

If you are a Java programmer who wants to build BlackBerry applications with Java, this book is for you.

Conventions

In this book, you will find several headings appearing frequently.

To give clear instructions of how to complete a procedure or task, we use:

Time for action - heading

  1. 1. Action 1

  2. 2. Action 2

  3. 3. Action 3

Instructions often need some extra explanation so that they make sense, so they are followed with:

What just happened?

This heading explains the working of tasks or instructions that you have just completed.

You will also find some other learning aids in the book, including:

Pop quiz - heading

These are short multiple choice questions intended to help you test your own understanding.

Have a go hero - heading

These set practical challenges and give you ideas for experimenting with what you have learned.

You will also find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Next, you need to find the HelloWorldDemo application."

A block of code is set as follows:

public class TipCalcApplication extends UiApplication {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}

Any command-line input or output is written as follows:

Feb 21, 2010 3:45:50 PM org.apache.coyote.http11.Http11BaseProtocol init SEVERE: Error initializing endpoint
java.net.BindException: Address already in use: JVM_Bind:8080

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: " Either go to File | Exit or simply close the simulator window".

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Note

Downloading the example code for this book

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.