Thông tin tài liệu
Karl G. Kowalski
RSA, The Security Division of EMC
Learn to:
• Download and work with the JDE
• Take advantage of developer tools,
including device and service simulators
• Create your own BlackBerry apps
• Submit your apps to BlackBerry App
World and get them accepted
BlackBerry
®
Application Development
Making Everything Easier!
™
Visit the companion Web site at www.dummies.com/
go/blackberryappdev to find source code files for the
code listings in the book.
Open the book and find:
• The tools you need to start
programming apps
• How to decide which JDE version
to download and use
• Pointers for creating menus and
screens
• Hints for using threads
• How to use different types of
storage in your app
• How to use simulators and real
devices to test your app
• Tips to get your app accepted to
BlackBerry App World
• How to submit multiple versions
of your app and upgrade it
Karl G. Kowalski writes application software for mobile platforms including
BlackBerry, iPhone, and J2ME devices. He has developed software for several
versions of the RSA SecurID® product, BlackBerry devices, and the first version
of RSA SecurID for iPhone devices.
$29.99 US / $35.99 CN / £21.99 UK
ISBN 978-0-470-46711-4
Programming/Application Development
Go to Dummies.com
®
for videos, step-by-step examples,
how-to articles, or to shop!
Be a part of the BlackBerry boom
and learn to program for one of
the hottest handhelds around
With more than 50 million BlackBerry users, it’s no wonder
the BlackBerry developer community is growing. Now you
can join the ranks. With this practical, hands-on guide, you’ll
develop an application from concept to completion. From
coding your app to uploading it to BlackBerry App World
and selling it, adding more juice to your BlackBerry apps has
never been easier!
• Discover the world of app development — register as a developer
and begin coding your first app
• Dive into code — create and display screens, accept and store
data, and use threads to multitask
• Create apps for the corporate enterprise — understand how the
BES can affect your app’s ability to run properly and connect to
networks
• Put the finishing touches on your app — debug your application
both on a simulator and on a real device
• Sell your app — deploy your app to BlackBerry App World and
upgrade it down the road
BlackBerry
®
Application
Development
Kowalski
Spine: .816”
www.it-ebooks.info
Spine: .816”
Start with FREE Cheat Sheets
Cheat Sheets include
• Checklists
• Charts
• Common Instructions
• And Other Good Stuff!
Get Smart at Dummies.com
Dummies.com makes your life easier with 1,000s
of answers on everything from removing wallpaper
to using the latest version of Windows.
Check out our
• Videos
• Illustrated Articles
• Step-by-Step Instructions
Plus, each month you can win valuable prizes by entering
our Dummies.com sweepstakes. *
Want a weekly dose of Dummies? Sign up for Newsletters on
• Digital Photography
• Microsoft Windows & Office
• Personal Finance & Investing
• Health & Wellness
• Computing, iPods & Cell Phones
• eBay
• Internet
• Food, Home & Garden
Find out “HOW” at Dummies.com
*Sweepstakes not currently available in all countries; visit Dummies.com for official rules.
Get More and Do More at Dummies.com
®
To access the Cheat Sheet created specifically for this book, go to
www.dummies.com/cheatsheet/blackberryapplicationdevelopment
Mobile Apps
There’s a Dummies App for This and That
With more than 200 million books in print and over 1,600 unique
titles, Dummies is a global leader in how-to information. Now
you can get the same great Dummies information in an App. With
topics such as Wine, Spanish, Digital Photography, Certification,
and more, you’ll have instant access to the topics you need to
know in a format you can trust.
To get information on all our Dummies apps, visit the following:
www.Dummies.com/go/mobile from your computer.
www.Dummies.com/go/iphone/apps from your phone.
www.it-ebooks.info
by Karl G. Kowalski
Software developer for RSA Security
BlackBerry
®
Application Development
FOR
DUMmIES
‰
01_467114-ffirs.indd i01_467114-ffirs.indd i 8/30/10 1:03 PM8/30/10 1:03 PM
www.it-ebooks.info
BlackBerry
®
Application Development For Dummies
®
Published by
Wiley Publishing, Inc.
111 River Street
Hoboken, NJ 07030-5774
www.wiley.com
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permit-
ted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written
permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the
Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600.
Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley
& Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://
www.wiley.com/go/permissions.
Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the
Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, Making Everything
Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/
or its af liates in the United States and other countries, and may not be used without written permission.
BlackBerry is a trademark or registered trademark of Research In Motion Limited. All other trademarks
are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or
vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO
REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF
THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITH-
OUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE
CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES
CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE
UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR
OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF
A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE
AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZA-
TION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF
FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE
INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY
MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK
MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT
IS READ. FULFILLMENT OF EACH COUPON OFFER IS THE SOLE RESPONSIBILITY OF THE OFFEROR.
For general information on our other products and services, please contact our Customer Care
Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.
For technical support, please visit www.wiley.com/techsupport.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may
not be available in electronic books.
Library of Congress Control Number: 2010935568
ISBN: 978-0-470-46711-4
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
01_467114-ffirs.indd ii01_467114-ffirs.indd ii 8/30/10 1:03 PM8/30/10 1:03 PM
www.it-ebooks.info
About the Author
Karl Kowalski has traveled the world of software development for far longer
than he really wants to remember. He has written code for everything from
airplanes, to voice recognition, to robot submarines, to games, and even
particle accelerators, and he has developed software on everything from
mainframes to cellphones. He lives near Boston and works for RSA, the
Security Division of EMC, where his tasks include developing security
solutions for mobile platforms, most especially the BlackBerry smartphone.
In his spare time, he develops software for smartphones such as BlackBerry,
iPhone, and Android as part of his startup, BlazingApps LLC (www.blazing
apps.com).
Dedication
To my parents, Stanley and Constance Kowalski, who are always there for
me, and who at every step helped me to become who I am today. Thanks,
Dad, for introducing me to programming computers, back before I could do
algebra. To my siblings — Lee Anne, Rosemarie, and Joseph — who always
kept me honest about taking time off from writing. Special thanks to Lee Anne
who helped me get started when I rst mentioned the idea. To my friend
Pauline, who saw me through some of the hard parts of becoming a writer.
Finally, to the members of the RSA Credentials Everywhere team: I couldn’t
have done this without your encouragement and support.
Author’s Acknowledgments
Many thanks go to Carole Jelen, agent extraordinaire, who never gave up on
me nor let me give up on myself. Acquisitions Editor Katie Mohr helped me
greatly through my learning to write For Dummies experience and also with
ideas and motivation for moving ahead. Project Editor Jean Nelson deserves
enormous thanks for putting up with a wet-behind-the-ears writer as I worked
to stay on target and stick to the schedule. Senior Copy Editor Teresa Artman
was very helpful in her efforts to take my typing and turn it into something
readable. Special thanks also to Leah Cameron for her feedback as I learned
to write For Dummies. Thanks to Christopher Parsons for his technical review.
Thanks to Robert Philpott at EMC for his work to ensure that I maintained a
distinct separation between my EMC efforts and my writing efforts.
01_467114-ffirs.indd iii01_467114-ffirs.indd iii 8/30/10 1:03 PM8/30/10 1:03 PM
www.it-ebooks.info
Publisher’s Acknowledgments
We’re proud of this book; please send us your comments at http://dummies.custhelp.com. For
other comments, please contact our Customer Care Department within the U.S. at 877-762-2974,
outside the U.S. at 317-572-3993, or fax 317-572-4002.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and Media
Development
Project Editor: Jean Nelson
Senior Acquisitions Editor: Katie Mohr
Senior Copy Editor: Teresa Artman
Technical Editor: Christopher Parsons (Bla1ze)
Editorial Manager: Kevin Kirschner
Media Development Project Manager:
Laura Moss-Hollister
Media Development Assistant Project
Manager: Jenny Swisher
Media Development Associate Producers:
Josh Frank, Marilyn Hummel,
Douglas Kuhn, Shawn Patrick
Editorial Assistant: Amanda Graham
Sr. Editorial Assistant: Cherie Case
Cartoons: Rich Tennant (
www.the5thwave.com)
Composition Services
Project Coordinators: Katherine Crocker,
Kristie Rees
Layout and Graphics: Samantha K. Cherolis,
Joyce Haughey, Christin Swinford
Proofreaders: Melissa D. Buddendeck,
Dwight Ramsey
Indexer: BIM Indexing & Proofreading Services
Publishing and Editorial for Technology Dummies
Richard Swadley, Vice President and Executive Group Publisher
Andy Cummings, Vice President and Publisher
Mary Bednarek, Executive Acquisitions Director
Mary C. Corder, Editorial Director
Publishing for Consumer Dummies
Diane Graves Steele, Vice President and Publisher
Composition Services
Debbie Stailey, Director of Composition Services
01_467114-ffirs.indd iv01_467114-ffirs.indd iv 8/30/10 1:03 PM8/30/10 1:03 PM
www.it-ebooks.info
Contents at a Glance
Introduction 1
Part I: Getting Started on BlackBerry Apps 7
Chapter 1: Gathering What You Need to Develop BlackBerry Apps 9
Chapter 2: Registering and Downloading 33
Chapter 3: Coding with the BlackBerry Java Development Environment 59
Part II: BlackBerry Application Development 77
Chapter 4: Designing and Organizing Your BlackBerry App 79
Chapter 5: Setting Up Screens and User Interfaces 109
Chapter 6: Storing Your Users’ Data 137
Chapter 7: Getting Tied Up in Threads 163
Part III: Developing Enterprise-Class BlackBerry Apps 197
Chapter 8: Writing Apps for the Enterprise 199
Chapter 9: Networking Your BlackBerry App 215
Part IV: Finishing and Debugging Your App 241
Chapter 10: Running Your Code on a Real Device 243
Chapter 11: Debugging Your Application 257
Chapter 12: Submitting to the BlackBerry App World 275
Part V: Securing and Supporting Your App 297
Chapter 13: Best Practices for Application Development 299
Chapter 14: Application Deployment and Upgrades 321
Part VI: The Part of Tens 337
Chapter 15: Ten Most Useful Sample BlackBerry Apps 339
Chapter 16: Ten BlackBerry Development Tips 343
Part VII: Appendixes 349
Appendix A: Device and Service Simulators 351
Appendix B: Real Devices and Services 365
Index 379
02_467114-ftoc.indd v02_467114-ftoc.indd v 8/30/10 1:03 PM8/30/10 1:03 PM
www.it-ebooks.info
02_467114-ftoc.indd vi02_467114-ftoc.indd vi 8/30/10 1:03 PM8/30/10 1:03 PM
www.it-ebooks.info
Table of Contents
Introduction 1
About This Book 1
Conventions Used in This Book 2
Foolish Assumptions 3
How This Book Is Organized 4
Icons Used in This Book 5
Where to Go from Here 6
Part I: Getting Started on BlackBerry Apps 7
Chapter 1: Gathering What You Need to Develop BlackBerry Apps. . . . 9
Why Develop BlackBerry Apps? 9
Discovering Apps, BlackBerry Style 11
Getting familiar with standard apps 11
Understanding how users navigate and use
their BlackBerry smartphones 12
Filling Your Toolbox 18
Downloading the software you need 18
Gathering BlackBerry simulators 19
Building or buying a development computer 20
Choosing a BlackBerry device 22
Using Your Programming Skills 23
Java programming for BlackBerry 24
Debugging 25
Using software patterns 25
Understanding BlackBerry Application Development Challenges 27
Choosing an OS version 27
Programming defensively 29
Entering a Brave, New BlackBerry App World 30
Deciding what kind of app to create 31
Brainstorming, alone or in groups 31
Becoming a BlackBerry developer and App World vendor 32
Chapter 2: Registering and Downloading . . . . . . . . . . . . . . . . . . . . . . . .33
Registering with RIM 33
Signing Up to Be a Citizen of the App World 37
Getting the JDE 42
Which JDE version is right for you? 44
Playing it safe 46
02_467114-ftoc.indd vii02_467114-ftoc.indd vii 8/30/10 1:03 PM8/30/10 1:03 PM
www.it-ebooks.info
BlackBerry Application Development For Dummies
viii
Downloading and Installing a JDE 47
Downloading and Using Alternate Device Simulators 50
Tapping Helpful Resources 54
Perusing the API documentation 54
Digging into online developer documentation 55
Exercising your Google-fu 57
Asking for help on the developer forums 57
Chapter 3: Coding with the BlackBerry Java Development
Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
Getting Familiar with the JDE 59
Creating a BlackBerry Application with the JDE 60
What does the JDE actually do? 61
The JDE display 63
Building and Running Your First BlackBerry App 64
Creating your rst app 65
Creating the display class 69
Building your application 72
Adding an Alternate Entry Point 74
Creating and con guring an AEP Project 74
Adding AEP code to your app’s main( ) routine 76
Part II: BlackBerry Application Development 77
Chapter 4: Designing and Organizing Your BlackBerry App . . . . . . . .79
Getting Creative and Keeping a Record 79
Planning What Your App Will Do 81
The Fundamentals of BlackBerry Applications 82
Parts of every BlackBerry app 83
The phases of a BlackBerry application 83
Handling Screens and Callbacks 92
Screen management 93
Callbacks: The Java version of phoning home 101
Chapter 5: Setting Up Screens and User Interfaces . . . . . . . . . . . . . .109
The Screen 110
Choosing a screen type 110
Creating a screen 111
Extending a screen’s basic functionality 114
User Interface Elements 115
User interface callbacks 117
Creating a custom user interface element 118
Menus 119
Understanding the MenuItem class 120
Creating a menu in a BlackBerry application 121
Responding to User Interaction 123
02_467114-ftoc.indd viii02_467114-ftoc.indd viii 8/30/10 1:03 PM8/30/10 1:03 PM
www.it-ebooks.info
[...]... and sell their applications to all BlackBerry users BlackBerry Application Development For Dummies shows you how to develop an application from concept to completion, from coding to uploading it to the BlackBerry App World to sell it to BlackBerry users About This Book BlackBerry Application Development For Dummies is a guide to developing BlackBerry smartphone applications No BlackBerry development experience... the entire set All through my early BlackBerry development, I searched for a book that would show me the whys and hows to get my applications working right I didn’t find anything Eventually, I decided it was time to write the book I had been searching for — BlackBerry Application Development For Dummies This book helps you sift through the resources of BlackBerry development to reveal only what’s absolutely... Java For Dummies, 4th Edition, by Barry Burd, or Java All-In-One Desk Reference For Dummies, 2nd Edition, by Doug Lowe and Barry Burd (all from Wiley Publishing) Sun’s online tutorials are helpful as well How This Book Is Organized The chapters in BlackBerry Application Development For Dummies are divided into seven parts Part I: Getting Started on BlackBerry Apps Part I takes you into the world of BlackBerry. .. world of BlackBerry application development You find out about BlackBerry applications in general, and you discover some of the challenges that your app might encounter on a BlackBerry smartphone You also discover how to become a registered BlackBerry developer and all the steps you need to take so you’re ready to deliver to the BlackBerry App World Part II: BlackBerry Application Development In Part... a BlackBerry application developer and downloaded the JDE, I recommend you hop right to Chapter 2 If you have a particular question or problem, check the Index or Table of Contents to find the information you need If you have questions or comments about the book or BlackBerry development in general, contact me at kgkfordummies@gmail.com You can also find additional information about my BlackBerry application, ... Macintosh OSX tool for BlackBerry development, unless you use a virtualization application (an application that allows you to run other operating systems within it) RIM offers a plug-in for the Eclipse development environment Eclipse is an open source (free) Java development environment you can download from www.eclipse.org This book concentrates on development using the RIM JDE, but if you’re comfortable using... the current version of BlackBerry Java Plug-in for Eclipse is 1.1, and makes use of the BlackBerry OS 5.0 APIs Information about the RIM Eclipse plugin can be found at http://na .blackberry. com/eng/developers/devbetasoftware/javaplugin.jsp Gathering BlackBerry simulators The BlackBerry JDE comes with several supporting applications to assist you in developing a quality BlackBerry application You use smartphone... of memory A good midrange computer with a large amount of memory, as much as it can use, will support your needs for BlackBerry application development Table 1-1 shows the requirements for a bare-bones development PC and for a development PC with power to spare Table 1-1 Requirements for a Development PC Equipment Minimum Requirements Optimum Requirements Processor 2.0 GHz processor 3.0 GHz multi-code... Part I: Getting Started on BlackBerry Apps Figure 1-1: The BlackBerry Curve Home Screen with the Browser application selected Figure 1-2: The Browser application in action Here are a few other reasons why I see the BlackBerry as a great development opportunity: ✓ BlackBerry applications tend to be small This makes them easy to develop and maintain, and they don’t require a large development team: You need... to run ✓ The BlackBerry Java Development Environment (JDE): You can get the JDE for free, but you must become a registered BlackBerry developer first Registration is also free Registering with RIM and downloading the JDE are covered in detail in Chapter 2 www.it-ebooks.info 03_467114-intro.indd 303_467114-intro.indd 3 8/30/10 1:03 PM8/30/10 1:03 PM 4 BlackBerry Application Development For Dummies And . advertise, and sell their
applications to all BlackBerry users.
BlackBerry Application Development For Dummies shows you how to develop
an application from concept. the
BlackBerry App World to sell it to BlackBerry users.
About This Book
BlackBerry Application Development For Dummies is a guide to developing
BlackBerry
Ngày đăng: 06/03/2014, 18:20
Xem thêm: BlackBerry Application Development For Dummies potx, BlackBerry Application Development For Dummies potx