BlackBerry Application Development For Dummies

pdf
Số trang BlackBerry Application Development For Dummies 412 Cỡ tệp BlackBerry Application Development For Dummies 6 MB Lượt tải BlackBerry Application Development For Dummies 0 Lượt đọc BlackBerry Application Development For Dummies 0
Đánh giá BlackBerry Application Development For Dummies
4 ( 13 lượt)
Nhấn vào bên dưới để tải tài liệu
Đang xem trước 10 trên tổng 412 trang, để tải xuống xem đầy đủ hãy nhấn vào bên trên
Chủ đề liên quan

Nội dung

Spine: .816” Programming/Application Development 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! • Dive into code — create and display screens, accept and store data, and use threads to multitask • 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 • Create apps for the corporate enterprise — understand how the BES can affect your app’s ability to run properly and connect to networks • Tips to get your app accepted to BlackBerry App World • Put the finishing touches on your app — debug your application both on a simulator and on a real device • How to submit multiple versions of your app and upgrade it ® • Discover the world of app development — register as a developer and begin coding your first app Open the book and find: BlackBerry Application Development Be a part of the BlackBerry boom and learn to program for one of the hottest handhelds around g Easier! Making Everythin ™ y r r e B k Blac velopment ® e D n o i t a c i l App • Sell your app — deploy your app to BlackBerry App World and upgrade it down the road Learn to: Visit the companion Web site at www.dummies.com/ go/blackberryappdev to find source code files for the code listings in the book. • Download and work with the JDE Go to Dummies.com® for videos, step-by-step examples, how-to articles, or to shop! • 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 $29.99 US / $35.99 CN / £21.99 UK 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. ISBN 978-0-470-46711-4 Karl G. Kowalski Kowalski RSA, The Security Division of EMC www.it-ebooks.info Spine: .816” Get More and Do More at Dummies.com ® Start with FREE Cheat Sheets Cheat Sheets include • Checklists • Charts • Common Instructions • And Other Good Stuff! To access the Cheat Sheet created specifically for this book, go to www.dummies.com/cheatsheet/blackberryapplicationdevelopment s p p A e l i Mob 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 There’s a Dummies App for This and That 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. www.it-ebooks.info 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. BlackBerry® Application Development FOR DUMmIES ‰ by Karl G. Kowalski Software developer for RSA Security www.it-ebooks.info 01_467114-ffirs.indd i01_467114-ffirs.indd i 8/30/10 1:03 PM8/30/10 1:03 PM 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 permitted 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 affiliates 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 WITHOUT 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 ORGANIZATION 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 www.it-ebooks.info 01_467114-ffirs.indd ii01_467114-ffirs.indd ii 8/30/10 1:03 PM8/30/10 1:03 PM 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 first 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. www.it-ebooks.info 01_467114-ffirs.indd iii01_467114-ffirs.indd iii 8/30/10 1:03 PM8/30/10 1:03 PM 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: Composition Services Acquisitions, Editorial, and Media Development Project Coordinators: Katherine Crocker, Kristie Rees Project Editor: Jean Nelson Senior Acquisitions Editor: Katie Mohr Senior Copy Editor: Teresa Artman Technical Editor: Christopher Parsons (Bla1ze) Editorial Manager: Kevin Kirschner Layout and Graphics: Samantha K. Cherolis, Joyce Haughey, Christin Swinford Proofreaders: Melissa D. Buddendeck, Dwight Ramsey Indexer: BIM Indexing & Proofreading Services 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) 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 www.it-ebooks.info 01_467114-ffirs.indd iv01_467114-ffirs.indd iv 8/30/10 1:03 PM8/30/10 1:03 PM 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 www.it-ebooks.info 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 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 www.it-ebooks.info 02_467114-ftoc.indd vii02_467114-ftoc.indd vii 8/30/10 1:03 PM8/30/10 1:03 PM viii BlackBerry Application Development For Dummies 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 first app ........................................................................ 65 Creating the display class ................................................................... 69 Building your application ................................................................... 72 Adding an Alternate Entry Point .................................................................. 74 Creating and configuring 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 www.it-ebooks.info 02_467114-ftoc.indd viii02_467114-ftoc.indd viii 8/30/10 1:03 PM8/30/10 1:03 PM
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.