Tải bản đầy đủ (.pdf) (368 trang)

BlackBerry Java Application Development Beginner''''s Guide pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (7.32 MB, 368 trang )

BlackBerry Java Application
Development
Beginner's Guide
Build and deploy powerful, useful, and professional Java
mobile applicaons for BlackBerry smartphones, the
fast and easy way
Bill Foust
BIRMINGHAM - MUMBAI
Do wnload from Wow! eBook <www.wowebook.com>
BlackBerry Java Application Development
Beginner's Guide
Copyright © 2010 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system,
or transmied in any form or by any means, without the prior wrien permission of the
publisher, except in the case of brief quotaons embedded in crical arcles or reviews.
Every eort has been made in the preparaon of this book to ensure the accuracy of the
informaon presented. However, the informaon contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly or
indirectly by this book.
Packt Publishing has endeavored to provide trademark informaon about all of the
companies and products menoned in this book by the appropriate use of capitals. However,
Packt Publishing cannot guarantee the accuracy of this informaon.
First published: July 2010
Producon Reference: 1190710
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-849690-20-1


www.packtpub.com
Cover Image by Parag Kadam ()
Credits
Author
Bill Foust
Reviewers
Richard Evers
Jason Reese
Acquision Editor
David Barnes
Development Editor
Mehul Shey
Technical Editor
Namita Sahni
Indexer
Monica Ajmera Mehta
Editorial Team Leader
Akshara Aware
Project Team Leader
Priya Mukherji
Project Coordinator
Ashwin Shey
Proofreader
Je Orlo
Producon Coordinators
Alwin Roy
Adline Swetha Jesuthas
Kruthika Bangera
Cover Work
Alwin Roy

About the Author
Bill Foust has been developing soware for over een years in a variety of elds and
technologies. He began working with BlackBerry devices in 1999—before they even had
built-in cellular phones! During that me, he created and sold applicaons, and helped
several companies develop product oerings for BlackBerry.
With the release of the BlackBerry 5810 in 2002, the development environment changed
from C++ to Java Micro and Bill started pursuing other opportunies, including .NET, and has
connued to do development as a consultant professionally since then.
In 2004, he authored the book Mobile Magazine Guide to BlackBerry with Que
Publishing (
/>dp/0789733439
). This book was a success and lead to Bill being a founding member of
the Mobile Compung Authority podcast with two other book authors.
Bill is currently working with a consulng company in Kansas City and connues to opine
about BlackBerry and the mobile compung industry in general through the Mobile
Compung Authority blog and podcasts.
Acknowledgement
First, I need to thank God, the Father, for everything that He has done throughout my life
and for the grace, favor, and peace to get this book done. The opportunity to write this book
came about at a me in my life that was not very convenient. I was looking at moving cross
country and a job change to help take care of my ailing mother. In spite of this, the many
challenges we faced to complete this book were never overwhelming and in the end,
were overcome.
Secondly, I need to thank my wife, Angela, and family for their connual support throughout
the enre process. Even as deadlines were missed and evenings were spent wring instead
of playing with the kids, my wife was understanding and supporve in seeing this done.
I also need to give special thanks to the sta at Packt Publishing for their paence and
understanding with me through all of the issues and delays we faced.
I’d like to dedicate this book to my mother, who passed away during the wring of this
book. We will miss you Mom.

About the Reviewers
Richard Evers develops soware in many languages across several plaorms, and has
extensive experience developing for Oracle, DB2, Informix, MySQL, and SQL Server.
He has been the editor of ve magazines, publisher of two magazines, author of thousands
of soware products, and publisher of eight educaonal websites.
Richard has been helped create books such as the Professional BlackBerry (Wrox), Mobile
PC Guide to BlackBerry (Que), the BlackBerry For Dummies series (Wiley), four BlackBerry
Cercaon Program self-study guides, the Civics Canada Online Textbook, The Complete
Commodore Inner Space Anthology, and The Transactor Book of Bits and Pieces.
Richard worked for Research In Moon for more than 7 years, and recently le RIM to work
for BlueCat Networks as a senior soware engineer.
I would like to thank my wife, Donna, and my children, Stephanie, Samantha,
and Adam, for their love and support through countless years of hiding
behind a computer screen.
Jason Reese has spent 12 years working in the telecommunicaons and wireless industries
managing global mobility projects, device deployments, support, and applicaon development
on all major mobile plaorms. Jason is a regular contributor to the technology site
GearDiary.com. When he’s not working, Jason enjoys traveling and spending me with his
wife, Stephanie, and their 5 year-old Boston Terrier, Sophie.
I would like to thank my wife, Stephanie, who has been incredibly
supporve (and paent!) through many years and projects.
Table of Contents
Preface 1
Chapter 1: Introducing BlackBerry Applicaon Development 7
Expectaons of this book 8
General device capabilies 9
Two dierent approaches to applicaon development 10
Choosing an SDK version 10
What you can expect 12
Summary 14

Chapter 2: Installing the Development Environment 15
System requirements 16
Development Environments 16
Downloading and installing Java 17
Time for acon – downloading the Java Development Kit 17
Time for acon – installing the Java Development Kit (JDK) 20
Introducing the BlackBerry Developer Zone 22
Downloading and installing Eclipse 23
Time for acon – downloading Eclipse with the JDE plugin 24
Time for acon – installing the JDE plugin for Eclipse Full installer 26
Installing other JDE component package versions 28
Time for acon – installing other JDE component packages over-the-air 28
Summary 36
Chapter 3: Geng Familiar with the Development Environment 37
Starng the Eclipse IDE 37
Time for acon – launching Eclipse for the rst me 38
Imporng the hello world project 42
Time for acon – imporng the HelloWorldDemo sample applicaon 42
Running the applicaon 46
Time for acon – running an applicaon in the simulator 47
Table of Contents
[ ii ]
Debugging the applicaon 49
Time for acon – starng the debugger 50
Introducing Eclipse perspecves 52
Time for acon – changing the perspecve 52
Geng some help! 55
Time for acon – displaying the Help 55
Summary 58
Chapter 4: Creang your First BlackBerry Project 59

Choosing the SDK version 59
Creang a new project 60
Time for acon – creang a new project 60
Adding a package to the new project 62
Time for acon – creang a new project 63
Start at the beginning 65
Applicaon and UiApplicaon 65
Time for acon – adding the UiApplicaon class 65
A closer look at the code 68
Time for acon – expanding TipCalcApplicaon 69
MainScreen 71
Time for acon – adding a MainScreen 72
Determining your screen requirements 73
Time for acon – expanding the TIpCalcMainScreen 74
Time for acon – adding more to the MainScreen 75
Adding a menu to the applicaon 78
Time for acon – adding a menu to the MainScreen 78
Seng the SDK version 81
Time for acon – selecng the right component package 81
Tesng it out 84
Time for acon – running your new applicaon 84
Giving TipCalc some polish 86
Adding an icon to TipCalc 87
Time for acon – adding an icon 88
Time for acon – changing the applicaon tle 92
Fixing the Bill Amount eld 93
Time for acon – xing the bill amount eld 93
Disabling the save prompt 94
Time for acon – disabling the "save" dialog 94
Summary 95

Table of Contents
[ iii ]
Chapter 5: Learning the Basics About the UI 97
Geng to know other Field classes 97
SeparatorField 101
Time for acon – creang a SeparatorField 101
LabelField 102
Time for acon – creang a LabelField 102
BitmapField 103
Time for acon – creang a BitmapField 104
ChoiceField 105
ObjectChoiceField 106
Time for acon – creang an ObjectChoiceField 106
NumericChoiceField 108
Time for acon – creang a NumericChoiceField 108
GaugeField 109
Time for acon – creang a GaugeField 110
DateField 113
Time for acon – creang a DateField 114
CheckboxField 116
Time for acon – creang a CheckboxField 117
RadioBuonField 118
Time for acon – creang a RadioBuonField 119
TextField 122
BasicEditField 122
Time for acon – creang a BasicEditField 124
EditField 126
Time for acon – creang an EditField 126
PasswordEditField 127
Time for acon – creang a PasswordEditField 127

EmailAddressEditField 128
Time for acon – creang an EmailAddressField 128
AutoTextEditField 129
Time for acon – creang an AutoTextEditField 129
AcveAutoTextEditField 131
Time for acon – creang an AcveAutoTextEditField 131
RichTextField 133
Time for acon – creang a RichTextField 133
AcveRichTextField 136
Time for acon – creang an AcveRichTextField 137
Summary 139
Table of Contents
[ iv ]
Chapter 6: Going Deeper into the UI 141
BuonField 142
Time for acon – creang a BuonField 142
ListField 145
Time for acon – creang a ListField 145
TreeField 149
Time for acon – creang a TreeField 150
MapField 154
Time for acon – creang a MapField 154
Displaying another screen 155
Time for acon – creang an "About Screen" 156
Displaying a dialog 158
Time for acon – collecng informaon with a common dialog 159
Time for acon – collecng informaon with custom buons on a dialog 160
Time for acon – collecng informaon with a list on a dialog 162
Listeners and callbacks 164
Layout managers 164

Special consideraons for touchscreens 165
TouchEvents and TouchGestures 166
Summary 168
Chapter 7: Storing Data 171
Laying the ground work 171
Creang a data class 172
The Java way: RMS 172
Time for acon – creang and opening a RecordStore 174
Time for acon – adding a record 177
Time for acon – retrieving records 179
Time for acon – deleng records 182
The BlackBerry way: Persistent Store 184
PersistentStore and PersistentObject 184
Time for acon – preparing the JournalEntry class 185
Time for acon – geng a PersistentObject 186
Time for acon – accessing the PersistentObject data 188
Time for acon – accessing the PersistentObject data 189
Accessing removable storage 192
Connector and FileConnecon 193
Time for acon – storing data to a le 193
Time for acon – reading data from a le 198
Summary 202
Table of Contents
[ v ]
Chapter 8: Interfacing with Applicaons 203
Introducing PIM 204
Why is all so generic? 204
PIMLists 205
PIMItems 205
Laying the ground work 206

Time for acon – creang test contacts 206
Expanding your test contacts 212
Time for acon – adding telephone numbers 212
Expanding even more 215
Time for acon – adding e-mail addresses 215
Finishing the test contacts 217
Time for acon – adding e-mail addresses 217
Embedding the address book into your applicaon 220
Time for acon – embedding the address book 220
Adding the event to your calendar 224
Time for acon – adding an event to the calendar 225
Recurring events 227
Sending e-mail 229
Time for acon – sending an e-mail from an applicaon 230
Summary 233
Chapter 9: Networking 235
Threading 236
Connector class 236
HTTP basics 237
HTTP GET requests 238
Time for acon - HTTP Basics 238
HTTP POST requests 244
Time for acon – calling a web service 245
Time for acon – parsing the response 250
The transport—so many possibilies 255
Direct TCP/IP 255
MDS/BES 256
BIS-B 256
Wi-Fi 257
WAP 257

WAP 1.X 257
WAP 2.0 258
Debugging with the MDS simulator 258
Tesng for availability of transports 262
Time for acon – tesng for availability 263
Table of Contents
[ vi ]
Moving beyond HTTP connecons 266
Summary 268
Chapter 10: Advanced Topics 269
Introducing the Global Posioning System 270
The LocaonProvider class 270
Criteria 271
Three ways to get GPS data 271
Bringing it all together 272
Geng coordinates 273
Time for acon – acquiring a locaon 274
Expanding Hansel 285
Time for acon – expanding Hansel 285
Alternate entry points 294
Creang a focus icon 295
Time for acon – creang an alternate entry point project 296
Time for acon – adding a focus icon to Hansel 298
Summary 304
Chapter 11: Wrapping It All Up 305
Using resources for localizaon 306
Time for acon – adding a resource le 306
Resource bundles 309
Time for acon – adding a second resource le 310
Time for acon – populang a resource le and conguring the project 311

Time for acon – using a resource in your code 314
Code signing your applicaon 317
Time for acon – conguring projects to allow access 317
Time for acon – installing the code-signing keys 319
Time for acon – code-signing the applicaon 320
Distribung your applicaon through BlackBerry App World 324
Licensing models 325
Subming an applicaon 326
Summary 326
Appendix: Pop Quiz Answers 329
Chapter 2 329
Chapter 3 329
Chapter 4 330
Pop Quiz 1 330
Pop Quiz 2 330
Pop Quiz 3 330
Table of Contents
[ vii ]
Chapter 5 331
Pop Quiz 1 331
Pop Quiz 2 331
Pop Quiz 3 331
Pop Quiz 4 332
Pop Quiz 5 332
Chapter 6 332
Pop Quiz 1 332
Pop Quiz 2 333
Pop Quiz 3 333
Chapter 7 333
Pop Quiz 1 333

Pop Quiz 2 334
Pop Quiz 3 334
Chapter 8 334
Pop Quiz 1 334
Pop Quiz 2 335
Pop Quiz 3 335
Chapter 9 335
Pop Quiz 1 335
Pop Quiz 2 336
Pop Quiz 3 336
Chapter 10 336
Pop Quiz 1 336
Pop Quiz 2 337
Chapter 11 337
Index 457
Do wnload from Wow! eBook <www.wowebook.com>

Preface
The book teaches how to write rich, interacve, and smart BlackBerry applicaons 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, mulmedia, contacts and calendar, and so on. This book also helps you build your own
applicaons to illustrate the plaorm and the various capabilies that developers can use
in their programs.
What this book covers
Chapter 1, Introducing BlackBerry Applicaon Development gets you started by talking about
the capabilies of a BlackBerry smartphone and what kind of things can be done with these
capabilies with a custom applicaon. It talks about the other tools which are available and
why wring nave Java applicaons by using the BlackBerry SDK is the most powerful and

praccal approach to developing applicaons. 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
addional 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, Geng Familiar with the Development Environment starts o the learning
process by imporng an exisng sample applicaon—the standard "Hello World"
applicaon. Aer imporng the project, the chapter will go over this simple applicaon
line-by-line. Aerwards, you will run the applicaon in the simulator and then introduce
a bug into the applicaon so that you can debug it as well.
Preface
[ 2 ]
Chapter 4, Creang your rst 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 applicaon quickly using the User Interface (UI) elements provided by the
framework.
Chapter 5, Learning the Basics about the UI creates an applicaon to demonstrate each
of the UI elements that are available to you when using the BlackBerry SDK. This sample
applicaon demonstrates how to set and retrieve data from each eld and discusses
when each eld should be used according to the BlackBerry development guidelines. By
demonstrang each eld, you will get a complete understanding of the capabilies of
each eld.
Chapter 6, Going Deeper into the UI picks up where the previous chapter leaves o by
demonstrang how to use some of the advanced elds, such as lists and trees. It also covers
navigaon between screens, displaying dialogs, and common paerns used in the BlackBerry
SDK. By the me you are done with this chapter, you will be well equipped to create the
enre UI for an applicaon.

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-specic PersistentStore, and even how to access the removable media
cards that are available on some devices.
Chapter 8, Interfacing with Applicaons shows you how to take advantage of one of most
powerful features available to a BlackBerry applicaon. Each BlackBerry device comes with
standard applicaons that you can interface with. These include the address book, calendar,
and even the messaging applicaons. Being able to ghtly integrate an applicaon 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
applicaon networking aware. Here, you will discover what transports are available, how to
open connecons , and how to send data through them. The sample also demonstrates how
to communicate with a simple web service and parse the resulng XML data.
Chapter 10, Advanced Topics covers two disnct, but powerful topics. The rst topic is
how to ulize the built-in GPS receiver that is built in to some smartphones in order to
get locaon informaon. You will learn about the various methods that can be used to get
locaon informaon and how to do some common calculaons 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 mulple applicaons. Because these applicaons share a
common project, they can share code and even memory.
Preface
[ 3 ]
Chapter 11, Wrapping It All Up nishes the book with tasks that commonly are done last,
such as localizaon with language resource les and code-signing your applicaon so that
it can be installed on real devices. You will also learn what it takes to distribute your new
applicaon 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 Runme Environment) and JDE (Java
Development Environment), which are both needed to run Eclipse, the development
environment, and to compile the applicaons 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 soware 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 serializaon.
Who this book is for
If you are a Java programmer who wants to build BlackBerry applicaons with Java,
this book is for you.
Conventions
In this book, you will nd several headings appearing frequently.
To give clear instrucons of how to complete a procedure or task, we use:
Time for action – heading
1. Acon 1
2. Acon 2
3. Acon 3
Preface
[ 4 ]
Instrucons oen need some extra explanaon so that they make sense, so they are
followed with:
What just happened?
This heading explains the working of tasks or instrucons that you have just completed.
You will also nd some other learning aids in the book, including:
Pop quiz – heading
These are short mulple choice quesons intended to help you test your own understanding.
Have a go hero – heading
These set praccal challenges and give you ideas for experimenng with what you have

learned.
You will also nd a number of styles of text that disnguish between dierent kinds of
informaon. Here are some examples of these styles, and an explanaon of their meaning.
Code words in text are shown as follows: "Next, you need to nd the
HelloWorldDemo
applicaon."
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 wrien 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".
Do wnload from Wow! eBook <www.wowebook.com>
Preface
[ 5 ]
Warnings or important notes appear in a box like this.
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

tles that you really get the most out of.
To send us general feedback, simply send an e-mail to
, and
menon the book tle 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 experse in and you are interested in either wring or
contribung 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.
Downloading the example code for this book
You can download the example code les for all Packt books you have purchased
from your account at . If you purchased this
book elsewhere, you can visit and
register to have the les e-mailed directly to you.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen.
If you nd 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
frustraon and help us improve subsequent versions of this book. If you nd any errata, please
report them by vising selecng your book, clicking
on the let us know link, and entering the details of your errata. Once your errata are veried,
your submission will be accepted and the errata will be uploaded on our website, or added
to any list of exisng errata, under the Errata secon of that tle. Any exisng errata can be
viewed by selecng your tle from />Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt,
we take the protecon 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 locaon
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 protecng 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.
1
Introducing BlackBerry Application
Development
The BlackBerry family of devices has long been the undisputed king of e-mail
for business professionals. In recent years, the company that makes BlackBerry
handhelds, Research In Moon (RIM), has been making devices targeted more
towards consumers with devices such as the Storm and Pearl. Because of this
shi the demand for quality applicaons has exploded in recent years. The
creaon of the BlackBerry App World has only fueled this growth and the size
of the opportunity. According to recent stascs, the BlackBerry App World has
the fewest number of tles and the highest average cost, all of which means
there is a big opportunity here!
Now, with more than 28 million subscribers and 60 million devices
manufactured, it is hard to go anywhere and not see someone using a
BlackBerry. Maybe you see these numbers as a ferle market for your
applicaon, or maybe your company has long ago standardized on
BlackBerry handhelds and you want to leverage that exisng investment.
Either way, you will learn how to tap into that potenal and create custom
applicaons for BlackBerry handhelds by using the object-oriented
development experience you already have.
Introducing BlackBerry Applicaon Development

[ 8 ]
In this chapter, we shall:
 Learn about the two approaches to applicaon development
 Learn generally what features can be used by an applicaon
 Understand how the SDK version relates to target devices
 Learn about the BlackBerry Developer Zone
So let's get on with it
Expectations of this book
This book is part of the Basic series which means we will start at the very beginning of the
learning curve. We start with the simplest task of geng the right tools downloaded and
installed. We then take you through to the nal stages of pung the last nishing touches
on your applicaon and then subming it to the BlackBerry App World so that the world can
use it. Along the way, we will cover each of the major areas of applicaon development: user
interface, storage, connecvity, and interfacing with other applicaons in ways that are clear
and useful.
There are a few things that we assume and that you should be familiar with before starng
down this road. The rst is an understanding of an object-oriented programming language.
BlackBerry development is done using Java, but you don't need to be a Java expert to get
started. Experience in C#, C++, or some other object-oriented language is enough to
get started.
Most of what we do will use the BlackBerry-specic APIs, but there are mes when an
understanding of basic Java framework is important, such as when we need to use threads.
For this I recommend having a Java book available as well.
The second is an understanding of general operang system concepts such as a le system,
messaging, events, processes, and threading. The BlackBerry APIs actually do a very good
job of hiding many of these details, but they are there and understanding them will help to
understand the big picture.
Chapter 1
[ 9 ]
General device capabilities

BlackBerry handhelds, like many smartphones today, are very powerful in spite of their
small size. The processing power and capabilies of these handhelds could accurately be
described as smaller versions of our desktops or laptops. They have many strong capabilies
yet have a small size that makes them convenient to carry around. This combinaon makes
smartphones in general, and BlackBerry handhelds in parcular, well suited for on-the-go
applicaons.
But just what can they do? There are so many possibilies! Let's take a look at the general
capabilies of BlackBerry handhelds.
 Every handheld has a keyboard designed for typing on it. BlackBerry handhelds have
always been specically designed to send and receive e-mail, and as a result, the
keyboards are well-suited for entering free-form data. The BlackBerry SDK oers
no less than ten dierent kinds of text elds that can be used in nearly any kind of
applicaon. Plus, if you need something special, you can always create your own!
 Another area that BlackBerry handhelds excel at is network connecvity. Again,
this is by design in order to provide excellent e-mail service. This connecvity
includes fully encrypted TCP/IP communicaon, and the ability to receive as well
as send raw data. Whether it be HTTP or UDP, the BlackBerry SDK supports all of
the major networking protocols and can handle receiving as well as sending data.
Furthermore, you can leverage the same secure protocols that are used to deliver
e-mail.
 Most applicaons will need to store data on the local device. Applicaons can,
of course, store data on the device in their own private stores, but they can also
access and interface with other applicaons on the handheld. These include the
pre-installed applicaons such as messages, address book, and calendar that come
with the handheld.
 Cameras are nearly ubiquitous on smartphones and can be accessed by an
applicaon as well.
 Many newer devices include removable memory card slots for storage of large
media les. Applicaons can access this storage as well to give applicaons with
large storage needs the room to work.

 Another feature that is extremely common on handhelds is a GPS receiver that
enables locaon-based service (LBS). This is one area that many in the smartphone
industry will say holds the most promise for the future.
Introducing BlackBerry Applicaon Development
[ 10 ]
Two different approaches to application development
If you've visited the BlackBerry Developer website you may have noced that there are
two recommended approaches to developing applicaons for BlackBerry handhelds—Java
Applicaon Development and BlackBerry Web Development. This book is focused on the
Java Applicaon Development approach, which is the more versale of the two, but the
other can be very useful in the right situaon.
 Java Applicaon Development approach: This is the most powerful approach
and it creates applicaons wrien in Java that are loaded onto and executed on
a BlackBerry handheld. They will be the focus of this book and are one of the
most common ways to deploy an applicaon. Two dierent tools exist to support
this approach—the BlackBerry Java Development Environment (JDE) and the
BlackBerry JDE Component Plug-in for Eclipse. Both oer the ability to create full
custom applicaons. The BlackBerry JDE is a custom applicaon wrien in Java that
can be used to develop applicaons. The laer leverages the Eclipse Integrated
Development Environment (IDE), which is a common plaorm for Java developers.
 BlackBerry Web Development approach: It is the other approach that runs
completely within the BlackBerry Browser applicaon and can use various
standards such as HTML and AJAX. Applicaons created using the BlackBerry Web
Development approach are similar to more common web applicaons and generally
require network connecvity to work. More powerful features, including nave API
calls, aren't allowed navely but can be made using BlackBerry Widgets. BlackBerry
Widgets is a separate SDK for creang small applets that can be leveraged by
web applicaons. Overall, this approach can be powerful but it requires network
connecvity, which potenally means data charges and/or delays for
network communicaon.

Choosing an SDK version
Before we dive into developing an applicaon we must choose the SDK version to work with.
In most environments, this choice is very simple—just choose the most recent version and
use that one. Unfortunately, things are not as simple for BlackBerry handhelds. In fact, it's
the opposite.
Do wnload from Wow! eBook <www.wowebook.com>

×