How does Fishpond Work?

We won't be beaten by anyone. Guaranteed

Android Wireless Application Development: Advanced Android v. II


Android Wireless Application Development has earned a reputation as the most useful real-world guide to building robust, commercial-grade Android apps. Now, authors Lauren Darcey and Shane Conder have systematically revised and updated this guide for the latest Android SDK and tools updates. To accommodate their extensive new coverage, they’ve split the book into two leaner, cleaner volumes. This Volume II focuses on advanced techniques for the entire app development cycle, including design, coding, testing, debugging, and distribution. Darcey and Conder cover hot topics ranging from tablet development to protecting against piracy and demonstrate advanced techniques for everything from data integration and UI development to in-app billing.


Every chapter has been thoroughly updated to reflect the latest SDKs, tools, and devices. The sample code has been completely overhauled and is available for download on a companion website. Drawing on decades of in-the-trenches experience as professional mobile developers, the authors also provide even more tips and best practises for highly efficient development. This new edition covers

  • Advanced app design with async processing, services, SQLite databases, content providers, intents, and notifications
  • Sophisticated UI development, including input gathering via gestures and voice recognition
  • Developing accessible and internationalised mobile apps
  • Maximising integrated search, cloud-based services, and other exclusive Android features
  • Leveraging Android 4.0 APIs for networking, web, location services, the camera, telephony, and hardware sensors
  • Building richer apps with 2D/3D graphics (OpenGL ES and RenderScript), animation, and the Android NDK
  • Tracking app usage patterns with Google Analytics
  • Streamlining testing with the Android Debug Bridge


This book is an indispensable resource for every intermediate- to advanced-level Java developer now participating in Android development and for every seasoned mobile developer who wants to take full advantage of the newest Android platform and hardware.


Also look for: Android Wireless Application Development, Volume I: Android Essentials (ISBN: 9780321813831)

Product Details

Table of Contents

Introduction 1Part I: Advanced Android Application Design PrinciplesChapter 1: Threading and Asynchronous Processing 9The Importance of Processing Asynchronously 9Working with the AsyncTask Class 10Working with the Thread Class 13Working with Loaders 14Understanding StrictMode 14Summary 15References and More Information 15Chapter 2: Working with Services 17Determining When to Use Services 17Understanding the Service Lifecycle 18Creating a Service 18Controlling a Service 23Implementing a Remote Interface 24Implementing a Parcelable Class 26Using the IntentService Class 29Summary 33References and More Information 33Chapter 3: Leveraging SQLite Application Databases 35Storing Structured Data Using SQLite Databases 35Creating a SQLite Database 36Creating, Updating, and Deleting Database Records 38Working with Transactions 40Querying SQLite Databases 41Closing and Deleting a SQLite Database 46Designing Persistent Databases 47Binding Data to the Application User Interface 50Summary 55References and More Information 55Chapter 4: Building Android Content Providers 57Acting as a Content Provider 57Implementing a Content Provider Interface 58Defining the Data URI 59Defining Data Columns 59Implementing Important Content Provider Methods 59Updating the Manifest File 65Enhancing Applications Using Content Providers 65Accessing Images on the Device 66Summary 71References and More Information 71Chapter 5: Broadcasting and Receiving Intents 73Sending Broadcasts 73Sending Basic Broadcasts 74Sending Ordered Broadcasts 74Receiving Broadcasts 75Registering to Receive Broadcasts 76Handling Incoming Broadcasts from the System 77Securing Application Broadcasts 80Summary 80References and More Information 81Chapter 6: Working with Notifications 83Notifying the User 83A Word on Compatibility 84Notifying with the Status Bar 84Using the NotificationManager Service 85Creating a Simple Text Notification with an Icon 85Working with the Notification Queue 86Updating Notifications 88Clearing Notifications 90Vibrating the Phone 91Blinking the Lights 92Making Noise 93Customizing the Notification 94Designing Useful Notifications 96Summary 97References and More Information 97Part II: Advanced Android User Interface Design PrinciplesChapter 7: Designing Powerful User Interfaces 99Following Android User Interface Guidelines 99Working with Menus 100Using Options Menus 100Using Context Menus 103Using Popup Menus 105Enabling Action Bars 105Building Basic Action Bars 106Customizing Your Action Bar 110Handling Application Icon Clicks on the Action Bar 112Working with Screens That Do Not Require Action Bars 114Introducing Contextual Action Mode 114Using Advanced Action Bar Features 114Working with Styles 114Building Simple Styles 115Leveraging Style Inheritance 117Working with Themes 119Summary 121References and More Information 122Chapter 8: Handling Advanced User Input 123Working with Textual Input Methods 123Working with Software Keyboards 123Working with Text Prediction and User Dictionaries 126Using the Clipboard Framework 126Handling User Events 127Listening for Touch Mode Changes 127Listening for Events on the Entire Screen 128Listening for Long Clicks 129Listening for Focus Changes 130Working with Gestures 131Detecting User Motions Within a View 131Handling Common Single-Touch Gestures 132Handling Common Multi-Touch Gestures 139Making Gestures Look Natural 142Using the Drag and Drop Framework 143Working with the Trackball 143Handling Screen Orientation Changes 144Summary 146References and More Information 147Chapter 9: Designing Accessible Applications 149Exploring the Accessibility Framework 149Leveraging Speech Recognition Services 151Leveraging Text-To-Speech Services 155Summary 158References and More Information 158Chapter 10: Best Practices for Tablet and Google TV Development 159Understanding Device Diversity 159Don't Make Assumptions about Device Characteristics 159Designing Flexible User Interfaces 160Attracting New Types of Users 161Leveraging Alternative Resources 161Using Screen Space Effectively on Big Landscape Screens 161Developing Applications for Tablets 162Developing Applications for Google TV 164Optimizing Web Applications for Google TV 165Developing Native Android Applications for Google TV 165Developing Apps for the Amazon Kindle Fire 166Summary 167References and More Information 168Part III: Leveraging Common Android APIsChapter 11: Using Android Networking APIs 169Understanding Mobile Networking Fundamentals 169Understanding Strict Mode with Networking 170Accessing the Internet (HTTP) 170Reading Data from the Web 170Using HttpURLConnection 171Parsing XML from the Network 172Handling Network Operations Asynchronously 174Retrieving Android Network Status 179Summary 181References and More Information 181Chapter 12: Using Android Web APIs 183Browsing the Web with WebView 183Designing a Layout with a WebView Control 184Loading Content into a WebView Control 184Adding Features to the WebView Control 186Managing WebView State 189Building Web Extensions Using WebKit 190Browsing the WebKit APIs 190Extending Web Application Functionality to Android 190Working with Flash 195Enabling Flash Applications 195Building AIR Applications for Android 196Summary 196References and More Information 196Chapter 13: Using Location-Based Services APIs 197Using Global Positioning Services (GPS) 197Using GPS Features in Your Applications 198Determining the Location of the Device 198Locating Your Emulator 200Geocoding Locations 200Mapping Locations 204Mapping Intents 205Mapping Views 206Getting Your Debug API Key 207Panning the Map View 209Zooming the Map View 210Marking the Spot 211Doing More with Location-Based Services 216Summary 217References and More Information 217Chapter 14: Using Android Multimedia APIs 219Working with Multimedia 219Working with the Camera 220Capturing Still Images Using the Camera 220Working with Video 229Working with Face Detection 233Working with Audio 233Recording Audio 233Playing Audio 235Sharing Audio 236Searching for Multimedia 236Working with Ringtones 238Summary 238References and More Information 238Chapter 15: Using Android Telephony APIs 239Working with Telephony Utilities 239Gaining Permission to Access Phone State Information 240Requesting Call State 240Requesting Service Information 242Monitoring Signal Strength and Data Connection Speed 243Working with Phone Numbers 243Using SMS 244Gaining Permission to Send and Receive SMS Messages 244Sending an SMS 245Receiving an SMS 247Making and Receiving Phone Calls 248Making Phone Calls 249Receiving Phone Calls 251Working with SIP 251Summary 251References and More Information 252Chapter 16: Accessing Android's Hardware Sensors 253Interacting with Device Hardware 253Using the Device Sensors 254Working with Different Sensors 254Configuring the Android Manifest File for Sensors 255Acquiring a Reference to a Sensor 256Reading Sensor Data 256Calibrating Sensors 258Determining Device Orientation 258Finding True North 258Monitoring the Battery 258Summary 261References and More Information 261Chapter 17: Using Android's Optional Hardware APIs 263Working with Bluetooth 263Checking for the Existence of BluetoothHardware 264Enabling Bluetooth 264Querying for Paired Devices 265Discovering Devices 265Establishing Connections Between Devices 266Working with USB 267Working with USB Accessories 268Working as a USB Host 269Working with Android Beam 269Enabling Android Beam Sending 270Receiving Android Beam Messages 271Configuring the Manifest File for Android Beam 272Working with Wi-Fi 273Introducing Wi-Fi Direct 273Monitoring Wi-Fi State 274Summary 276References and More Information 276Part IV: Drawing, Animations, and Graphics Programming with AndroidChapter 18: Developing Android 2D Graphics Applications 279Drawing on the Screen 279Working with Canvases and Paints 279Working with Text 284Using Default Fonts and Typefaces 284Using Custom Typefaces 285Measuring Text Screen Requirements 287Working with Bitmaps 287Drawing Bitmap Graphics on a Canvas 287Scaling Bitmap Graphics 287Transforming Bitmaps Using Matrixes 287Working with Shapes 289Defining Shape Drawables as XML Resources 289Defining Shape Drawables Programmatically 290Drawing Different Shapes 291Leveraging Hardware Acceleration Features 297Controlling Hardware Acceleration 298Fine-Tuning Hardware Acceleration 298Summary 299References and More Information 299Chapter 19: Working with Animation 301Exploring Android's Animation Abilities 301Working with Frame-by-Frame Animation 302Working with Tweened Animations 304Working with Property Animation 309Working with Different Interpolators 313Summary 314References and More Information 314Chapter 20: Developing Android 3D Graphics Applications 315Working with OpenGL ES 315Leveraging OpenGL ES in Android 316Ensuring Device Compatibility 316Using OpenGL ES APIs in the Android SDK 317Handling OpenGL ES Tasks Manually 318Creating a SurfaceView 318Starting Your OpenGL ES Thread 319Initializing EGL 321Initializing GL 323Drawing on the Screen 323Drawing 3D Objects 325Drawing Your Vertices 325Coloring Your Vertices 326Drawing More Complex Objects 327Lighting Your Scene 329Texturing Your Objects 331Interacting with Android Views and Events 333Enabling the OpenGL Thread to Talk to the Application Thread 333Enabling the Application Thread to Talk to the OpenGL Thread 335Cleaning Up OpenGL ES 337Using GLSurfaceView (Easy OpenGL ES) 337Using OpenGL ES 2.0 341Configuring Your Application for OpenGL ES 2.0 341Requesting an OpenGL ES 2.0 Surface 341Working with RenderScript 345Defining RenderScript Functionality 346Rendering to a Custom View Control 350Summary 353References and More Information 353Chapter 21: Using the Android NDK 355Determining When to Use the Android NDK 355Installing the Android NDK 356Exploring the Android NDK 357Running an Android NDK Sample Application 357Creating Your Own NDK Project 357Calling Native Code from Java 358Handling Parameters and Return Values 359Using Exceptions with Native Code 360Using Native Activities 362Improving Graphics Performance 362A Comparison to RenderScript 363Summary 363References and More Information 364Part V: Maximizing Android's Unique FeaturesChapter 22: Extending Android Application Reach 365Enhancing Your Applications 365Working with App Widgets 366Creating an App Widget 367Installing an App Widget 374Becoming an App Widget Host 375Working with Live Wallpapers 375Creating a Live Wallpaper 376Creating a Live Wallpaper Service 376Creating a Live Wallpaper Configuration 378Configuring the Android Manifest File for Live Wallpapers 379Installing a Live Wallpaper 379Acting as a Content Type Handler 381Determining Intent Actions and MIME Types 382Implementing the Activity to Process the Intents 383Registering the Intent Filter 384Summary 384References and More Information 384Chapter 23: Enabling Application Search 385Making Application Content Searchable 385Enabling Searches in Your Application 386Enabling Global Search 395Summary 398References and More Information 398Chapter 24: Working with Cloud to Device Messaging 399An Overview of C2DM 399Understanding C2DM Message Flow 400Understanding the Limitations of the C2DM Service 400Signing Up for C2DM 401Incorporating C2DM into Your Applications 402Exploring the C2DM Sample Applications 403What Alternatives to C2DM Exist? 403Summary 404References and More Information 404Chapter 25: Managing User Accounts and Synchronizing User Data 405Managing Accounts with the Account Manager 405Synchronizing Data with Sync Adapters 406Using Backup Services 407Choosing a Remote Backup Service 408Implementing a Backup Agent 409Backing Up and Restoring Application Data 412Summary 414References and More Information 414Part VI: Advanced Topics in Application Publication and DistributionChapter 26: Internationalizing Your Applications 415Internationalizing Applications 415Internationalization Using Alternative Resources 416Implementing Locale Support Programmatically 421Publishing Applications for Foreign Users 422Summary 422References and More Information 422Chapter 27: An Overview of Third-Party In-App Billing APIs for Android 423What Is In-App Billing? 423Using In-App Billing 424Leveraging Android Market In-App Billing APIs 425Leveraging Amazon Appstore In-App Billing APIs 426Leveraging PayPal Billing APIs 426Leveraging Other Billing APIs 427Summary 427References and More Information 427Chapter 28: Enabling Application Statistics with Google Analytics 429Creating a Google Account for Analytics 429Adding the Library to Your Eclipse Project 431Collecting Data from Your Applications 432Logging Different Events 432Using the Google Analytics Dashboard 433Gathering eCommerce Information 436Logging eCommerce Events in Your Applications 436Reviewing eCommerce Reports 437Tracking Ad and Market Referrals 438Gathering Statistics 438Protecting Users' Privacy 439Summary 439References and More Information 439Chapter 29: Protecting Applications from Software Piracy 441All Applications Are Vulnerable 441Using Secure Coding Practices 442Obfuscating with ProGuard 442Configuring ProGuard for Your Android Applications 443Dealing with Error Reports After Obfuscation 444Leveraging the License Verification Library 444Other Anti-Piracy Tips 445Summary 446References and More Information 446Part VII: AppendicesAppendix A: The Android Debug Bridge Quick-Start Guide 447Listing Connected Devices and Emulators 447Directing ADB Commands to Specific Devices 448Starting and Stopping the ADB Server 448Stopping the ADB Server Process 448Starting and Checking the ADB Server Process 448Listing ADB Commands 448Issuing Shell Commands 449Issuing a Single Shell Command 449Using a Shell Session 449Using the Shell to Start and Stop the Emulator 450Copying Files 450Sending Files to a Device or Emulator 450Retrieving Files from a Device or Emulator 450Installing and Uninstalling Applications 451Installing Applications 451Reinstalling Applications 451Uninstalling Applications 452Working with LogCat Logging 452Displaying All Log Information 452Including Date and Time with Log Data 452Filtering Log Information 453Clearing the Log 454Redirecting Log Output to a File 454Accessing the Secondary Logs 455Controlling the Backup Service 455Forcing Backup Operations 455Forcing Restore Operations 456Wiping Archived Data 456Generating Bug Reports 456Using the Shell to Inspect SQLite Databases 456Using the Shell to Stress Test Applications 456Letting the Monkey Loose on Your Application 457Listening to Your Monkey 457Directing Your Monkey's Actions 457Training Your Monkey to Repeat His Tricks 459Keeping the Monkey on a Leash 459Learning More About Your Monkey 459Installing Custom Binaries via the Shell 459Appendix B: The SQLite Quick-Start Guide 463Exploring Common Tasks with SQLite 463Using the sqlite3 Command-Line Interface 464Launching the ADB Shell 464Connecting to a SQLite Database 464Exploring Your Database 465Importing and Exporting the Database and Its Data 466Executing SQL Commands on the Command Line 468Using Other sqlite3 Commands 469Understanding SQLite Limitations 469Learning by Example: A Student Grade Database 469Designing the Student Grade Database Schema 470Creating Simple Tables with AUTOINCREMENT 470Inserting Data into Tables 471Querying Tables for Results with SELECT 471Using Foreign Keys and Composite Primary Keys 472Altering and Updating Data in Tables 473Querying Multiple Tables Using JOIN 474Using Calculated Columns 474Using Subqueries for Calculated Columns 476Deleting Tables 476Index 477

About the Author

Lauren Darcey is responsible for the technical leadership and direction of a small software company specializing in mobile technologies, including Android, Apple iOS, Blackberry, Palm Pre, BREW, J2ME, and consulting services. With more than two decades of experience in professional software production, Lauren is a recognized authority in application architecture and the development of commercial-grade mobile applications. Lauren received a B.S. in computer science from the University of California, Santa Cruz.She spends her free time traveling the world with her geeky mobile-minded husband and daughter. She is an avid nature photographer. Her work has been published in books and newspapers around the world. In South Africa, she dove with 4-meter-long great white sharks and got stuck between a herd of rampaging hippopotami and an irritated bull elephant. She's been attacked by monkeys in Japan, gotten stuck in a ravine with two hungry lions in Kenya, gotten thirsty in Egypt, narrowly avoided a coup d'etat in Thailand, geocached her way through the Swiss Alps, drank her way through the beer halls of Germany, slept in the crumbling castles of Europe, and had her tongue stuck to an iceberg in Iceland (while being watched by a herd of suspicious wild reindeer).Shane Conder has extensive development experience and has focused his attention on mobile and embedded development for the past decade. He has designed and developed many commercial applications for Android, iOS, BREW, Blackberry, J2ME, Palm, and Windows Mobile--some of which have been installed on millions of phones worldwide. Shane has written extensively about the mobile industry and evaluated mobile development platforms on his tech blogs. He is well-known within the blogosphere. Shane received a B.S. in computer science from the University of California. A self-admitted gadget freak, Shane always has the latest smartphone, tablet, or other mobile device. He can often be found fiddling with the latest technologies, such as cloud services and mobile platforms, and other exciting, state-of-the-art technologies that activate the creative part of his brain. He is a very hands-on geek dad. He also enjoys traveling the world with his geeky wife, even if she did make him dive with 4-meter-long great white sharks and almost got him eaten by a lion in Kenya. He admits that he has to take at least two phones with him when backpacking--even though there is no coverage--and that he snickered and whipped out his Android phone to take a picture when Laurie got her tongue stuck to that iceberg in Iceland, and that he is catching on that he should be writing his own bio.The authors have also published several other Android books, including Android Wireless Application Development, Android Wireless Application Development Volume I: Android Essentials, Sams Teach Yourself Android Application Development, Learning Android Application Programming for the Kindle Fire, and the mini-book Introducing Android Development with Ice Cream Sandwich. Lauren and Shane have also published numerous articles on mobile software development for magazines, technical journals, and online publishers of educational content. You can find dozens of samples of their work in Linux User and Developer, Smart Developer magazine (Linux New Media),, Network World, Envato (MobileTuts+ and CodeCanyon), and InformIT, among others. They also publish articles of interest to their readers at their own Android website, can find a full list of the authors' publications at

Look for similar items by category
Home » Books
How Fishpond Works
Fishpond works with suppliers all over the world to bring you a huge selection of products, really great prices, and delivery included on over 25 million products that we sell. We do our best every day to make Fishpond an awesome place for customers to shop and get what they want — all at the best prices online.
Webmasters, Bloggers & Website Owners
You can earn a 5% commission by selling Android Wireless Application Development: Advanced Android v. II: Advanced Topics: 2 (Developer's Library) on your website. It's easy to get started - we will give you example code. After you're set-up, your website can earn you money while you work, play or even sleep! You should start right now!
Authors / Publishers
Are you the Author or Publisher of a book? Or the manufacturer of one of the millions of products that we sell. You can improve sales and grow your revenue by submitting additional information on this title. The better the information we have about a product, the more we will sell!
Item ships from and is sold by Fishpond World Ltd.
Back to top