Android Wireless Application Development Volume II - Lauren Darcey, Shane Conder

Android Wireless Application Development Volume II

Advanced Topics
Buch | Softcover
528 Seiten
2012 | 3rd edition
Addison-Wesley Educational Publishers Inc (Verlag)
978-0-321-81384-8 (ISBN)
39,50 inkl. MwSt
zur Neuauflage
  • Titel erscheint in neuer Auflage
  • Artikel merken
Zu diesem Artikel existiert eine Nachauflage
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 practices 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 internationalized mobile apps
Maximizing 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)

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), developer.com, Network World, Envato (MobileTuts+ and CodeCanyon), and InformIT, among others. They also publish articles of interest to their readers at their own Android website, http://androidbook.blogspot.com.You can find a full list of the authors’ publications at http://goo.gl/f0Vlj.

Introduction     1

Part I: Advanced Android Application Design Principles

Chapter 1: Threading and Asynchronous Processing      9

The Importance of Processing Asynchronously      9

Working with the AsyncTask Class      10

Working with the Thread Class      13

Working with Loaders      14

Understanding StrictMode      14

Summary      15

References and More Information      15

Chapter 2: Working with Services      17

Determining When to Use Services      17

Understanding the Service Lifecycle      18

Creating a Service      18

Controlling a Service      23

Implementing a Remote Interface      24

Implementing a Parcelable Class      26

Using the IntentService Class      29

Summary      33

References and More Information      33

Chapter 3: Leveraging SQLite Application Databases      35

Storing Structured Data Using SQLite Databases      35

Creating a SQLite Database      36

Creating, Updating, and Deleting Database Records      38

Working with Transactions      40

Querying SQLite Databases      41

Closing and Deleting a SQLite Database      46

Designing Persistent Databases      47

Binding Data to the Application User Interface      50

Summary      55

References and More Information      55

Chapter 4: Building Android Content Providers      57

Acting as a Content Provider      57

Implementing a Content Provider Interface      58

Defining the Data URI      59

Defining Data Columns      59

Implementing Important Content Provider Methods      59

Updating the Manifest File      65

Enhancing Applications Using Content Providers      65

Accessing Images on the Device      66

Summary      71

References and More Information      71

Chapter 5: Broadcasting and Receiving Intents      73

Sending Broadcasts      73

Sending Basic Broadcasts      74

Sending Ordered Broadcasts      74

Receiving Broadcasts      75

Registering to Receive Broadcasts      76

Handling Incoming Broadcasts from the System      77

Securing Application Broadcasts      80

Summary      80

References and More Information      81

Chapter 6: Working with Notifications      83

Notifying the User      83

A Word on Compatibility      84

Notifying with the Status Bar      84

Using the NotificationManager Service      85

Creating a Simple Text Notification with an Icon      85

Working with the Notification Queue      86

Updating Notifications      88

Clearing Notifications      90

Vibrating the Phone      91

Blinking the Lights      92

Making Noise      93

Customizing the Notification      94

Designing Useful Notifications      96

Summary      97

References and More Information      97

Part II: Advanced Android User Interface Design Principles

Chapter 7: Designing Powerful User Interfaces      99

Following Android User Interface Guidelines      99

Working with Menus      100

Using Options Menus      100

Using Context Menus      103

Using Popup Menus      105

Enabling Action Bars      105

Building Basic Action Bars      106

Customizing Your Action Bar      110

Handling Application Icon Clicks on the Action Bar      112

Working with Screens That Do Not Require Action Bars      114

Introducing Contextual Action Mode      114

Using Advanced Action Bar Features      114

Working with Styles      114

Building Simple Styles      115

Leveraging Style Inheritance      117

Working with Themes      119

Summary      121

References and More Information      122

Chapter 8: Handling Advanced User Input      123

Working with Textual Input Methods      123

Working with Software Keyboards      123

Working with Text Prediction and User Dictionaries      126

Using the Clipboard Framework      126

Handling User Events      127

Listening for Touch Mode Changes      127

Listening for Events on the Entire Screen      128

Listening for Long Clicks      129

Listening for Focus Changes      130

Working with Gestures      131

Detecting User Motions Within a View      131

Handling Common Single-Touch Gestures      132

Handling Common Multi-Touch Gestures      139

Making Gestures Look Natural      142

Using the Drag and Drop Framework      143

Working with the Trackball      143

Handling Screen Orientation Changes      144

Summary      146

References and More Information      147

Chapter 9: Designing Accessible Applications      149

Exploring the Accessibility Framework      149

Leveraging Speech Recognition Services      151

Leveraging Text-To-Speech Services      155

Summary      158

References and More Information      158

Chapter 10: Best Practices for Tablet and Google TV Development      159

Understanding Device Diversity      159

Don’t Make Assumptions about Device Characteristics      159

Designing Flexible User Interfaces      160

Attracting New Types of Users      161

Leveraging Alternative Resources      161

Using Screen Space Effectively on Big Landscape Screens      161

Developing Applications for Tablets      162

Developing Applications for Google TV      164

Optimizing Web Applications for Google TV      165

Developing Native Android Applications for Google TV      165

Developing Apps for the Amazon Kindle Fire      166

Summary      167

References and More Information      168

Part III: Leveraging Common Android APIs

Chapter 11: Using Android Networking APIs      169

Understanding Mobile Networking Fundamentals      169

Understanding Strict Mode with Networking      170

Accessing the Internet (HTTP)      170

Reading Data from the Web      170

Using HttpURLConnection      171

Parsing XML from the Network      172

Handling Network Operations Asynchronously      174

Retrieving Android Network Status      179

Summary      181

References and More Information      181

Chapter 12: Using Android Web APIs      183

Browsing the Web with WebView      183

Designing a Layout with a WebView Control      184

Loading Content into a WebView Control      184

Adding Features to the WebView Control      186

Managing WebView State      189

Building Web Extensions Using WebKit      190

Browsing the WebKit APIs      190

Extending Web Application Functionality to Android      190

Working with Flash      195

Enabling Flash Applications      195

Building AIR Applications for Android      196

Summary      196

References and More Information      196

Chapter 13: Using Location-Based Services APIs      197

Using Global Positioning Services (GPS)      197

Using GPS Features in Your Applications      198

Determining the Location of the Device      198

Locating Your Emulator      200

Geocoding Locations      200

Mapping Locations      204

Mapping Intents      205

Mapping Views      206

Getting Your Debug API Key      207

Panning the Map View      209

Zooming the Map View      210

Marking the Spot      211

Doing More with Location-Based Services      216

Summary      217

References and More Information      217

Chapter 14: Using Android Multimedia APIs      219

Working with Multimedia      219

Working with the Camera      220

Capturing Still Images Using the Camera      220

Working with Video      229

Working with Face Detection      233

Working with Audio      233

Recording Audio      233

Playing Audio      235

Sharing Audio      236

Searching for Multimedia      236

Working with Ringtones      238

Summary      238

References and More Information      238

Chapter 15: Using Android Telephony APIs      239

Working with Telephony Utilities      239

Gaining Permission to Access Phone State Information      240

Requesting Call State      240

Requesting Service Information      242

Monitoring Signal Strength and Data Connection Speed      243

Working with Phone Numbers      243

Using SMS      244

Gaining Permission to Send and Receive SMS Messages      244

Sending an SMS      245

Receiving an SMS      247

Making and Receiving Phone Calls      248

Making Phone Calls      249

Receiving Phone Calls      251

Working with SIP      251

Summary      251

References and More Information      252

Chapter 16: Accessing Android’s Hardware Sensors      253

Interacting with Device Hardware      253

Using the Device Sensors      254

Working with Different Sensors      254

Configuring the Android Manifest File for Sensors      255

Acquiring a Reference to a Sensor      256

Reading Sensor Data      256

Calibrating Sensors      258

Determining Device Orientation      258

Finding True North      258

Monitoring the Battery      258

Summary      261

References and More Information      261

Chapter 17: Using Android’s Optional Hardware APIs      263

Working with Bluetooth      263

Checking for the Existence of Bluetooth

Hardware      264

Enabling Bluetooth      264

Querying for Paired Devices      265

Discovering Devices      265

Establishing Connections Between Devices      266

Working with USB      267

Working with USB Accessories      268

Working as a USB Host      269

Working with Android Beam      269

Enabling Android Beam Sending      270

Receiving Android Beam Messages      271

Configuring the Manifest File for Android Beam      272

Working with Wi-Fi      273

Introducing Wi-Fi Direct      273

Monitoring Wi-Fi State      274

Summary      276

References and More Information      276

Part IV: Drawing, Animations, and Graphics Programming with Android

Chapter 18: Developing Android 2D Graphics Applications      279

Drawing on the Screen      279

Working with Canvases and Paints      279

Working with Text      284

Using Default Fonts and Typefaces      284

Using Custom Typefaces      285

Measuring Text Screen Requirements      287

Working with Bitmaps      287

Drawing Bitmap Graphics on a Canvas      287

Scaling Bitmap Graphics      287

Transforming Bitmaps Using Matrixes      287

Working with Shapes      289

Defining Shape Drawables as XML Resources      289

Defining Shape Drawables Programmatically      290

Drawing Different Shapes      291

Leveraging Hardware Acceleration Features      297

Controlling Hardware Acceleration      298

Fine-Tuning Hardware Acceleration      298

Summary      299

References and More Information      299

Chapter 19: Working with Animation      301

Exploring Android’s Animation Abilities      301

Working with Frame-by-Frame Animation      302

Working with Tweened Animations      304

Working with Property Animation      309

Working with Different Interpolators      313

Summary      314

References and More Information      314

Chapter 20: Developing Android 3D Graphics Applications      315

Working with OpenGL ES      315

Leveraging OpenGL ES in Android      316

Ensuring Device Compatibility      316

Using OpenGL ES APIs in the Android SDK      317

Handling OpenGL ES Tasks Manually      318

Creating a SurfaceView      318

Starting Your OpenGL ES Thread      319

Initializing EGL      321

Initializing GL      323

Drawing on the Screen      323

Drawing 3D Objects      325

Drawing Your Vertices      325

Coloring Your Vertices      326

Drawing More Complex Objects      327

Lighting Your Scene      329

Texturing Your Objects      331

Interacting with Android Views and Events      333

Enabling the OpenGL Thread to Talk to the Application Thread      333

Enabling the Application Thread to Talk to the OpenGL Thread      335

Cleaning Up OpenGL ES      337

Using GLSurfaceView (Easy OpenGL ES)      337

Using OpenGL ES 2.0      341

Configuring Your Application for OpenGL ES 2.0      341

Requesting an OpenGL ES 2.0 Surface      341

Working with RenderScript      345

Defining RenderScript Functionality      346

Rendering to a Custom View Control      350

Summary      353

References and More Information      353

Chapter 21: Using the Android NDK      355

Determining When to Use the Android NDK      355

Installing the Android NDK      356

Exploring the Android NDK      357

Running an Android NDK Sample Application      357

Creating Your Own NDK Project      357

Calling Native Code from Java      358

Handling Parameters and Return Values      359

Using Exceptions with Native Code      360

Using Native Activities      362

Improving Graphics Performance      362

A Comparison to RenderScript      363

Summary      363

References and More Information      364

Part V: Maximizing Android’s Unique Features

Chapter 22: Extending Android Application Reach      365

Enhancing Your Applications      365

Working with App Widgets      366

Creating an App Widget      367

Installing an App Widget      374

Becoming an App Widget Host      375

Working with Live Wallpapers      375

Creating a Live Wallpaper      376

Creating a Live Wallpaper Service      376

Creating a Live Wallpaper Configuration      378

Configuring the Android Manifest File for Live Wallpapers      379

Installing a Live Wallpaper      379

Acting as a Content Type Handler      381

Determining Intent Actions and MIME Types      382

Implementing the Activity to Process the Intents      383

Registering the Intent Filter      384

Summary      384

References and More Information      384

Chapter 23: Enabling Application Search      385

Making Application Content Searchable      385

Enabling Searches in Your Application      386

Enabling Global Search      395

Summary      398

References and More Information      398

Chapter 24: Working with Cloud to Device Messaging      399

An Overview of C2DM      399

Understanding C2DM Message Flow      400

Understanding the Limitations of the C2DM Service      400

Signing Up for C2DM      401

Incorporating C2DM into Your Applications      402

Exploring the C2DM Sample Applications      403

What Alternatives to C2DM Exist?      403

Summary      404

References and More Information      404

Chapter 25: Managing User Accounts and Synchronizing User Data      405

Managing Accounts with the Account Manager      405

Synchronizing Data with Sync Adapters      406

Using Backup Services      407

Choosing a Remote Backup Service      408

Implementing a Backup Agent      409

Backing Up and Restoring Application Data      412

Summary      414

References and More Information      414

Part VI: Advanced Topics in Application Publication and Distribution

Chapter 26: Internationalizing Your Applications      415

Internationalizing Applications      415

Internationalization Using Alternative Resources      416

Implementing Locale Support Programmatically      421

Publishing Applications for Foreign Users      422

Summary      422

References and More Information      422

Chapter 27: An Overview of Third-Party In-App Billing APIs for Android      423

What Is In-App Billing?      423

Using In-App Billing      424

Leveraging Android Market In-App Billing APIs      425

Leveraging Amazon Appstore In-App Billing APIs      426

Leveraging PayPal Billing APIs      426

Leveraging Other Billing APIs      427

Summary      427

References and More Information      427

Chapter 28: Enabling Application Statistics with Google Analytics      429

Creating a Google Account for Analytics      429

Adding the Library to Your Eclipse Project      431

Collecting Data from Your Applications      432

Logging Different Events      432

Using the Google Analytics Dashboard      433

Gathering eCommerce Information      436

Logging eCommerce Events in Your Applications      436

Reviewing eCommerce Reports      437

Tracking Ad and Market Referrals      438

Gathering Statistics      438

Protecting Users’ Privacy      439

Summary      439

References and More Information      439

Chapter 29: Protecting Applications from Software Piracy      441

All Applications Are Vulnerable      441

Using Secure Coding Practices      442

Obfuscating with ProGuard      442

Configuring ProGuard for Your Android Applications      443

Dealing with Error Reports After Obfuscation      444

Leveraging the License Verification Library      444

Other Anti-Piracy Tips      445

Summary      446

References and More Information      446

Part VII: Appendices

Appendix A: The Android Debug Bridge Quick-Start Guide      447

Listing Connected Devices and Emulators      447

Directing ADB Commands to Specific Devices      448

Starting and Stopping the ADB Server      448

Stopping the ADB Server Process      448

Starting and Checking the ADB Server Process      448

Listing ADB Commands      448

Issuing Shell Commands      449

Issuing a Single Shell Command      449

Using a Shell Session      449

Using the Shell to Start and Stop the Emulator      450

Copying Files      450

Sending Files to a Device or Emulator      450

Retrieving Files from a Device or Emulator      450

Installing and Uninstalling Applications      451

Installing Applications      451

Reinstalling Applications      451

Uninstalling Applications      452

Working with LogCat Logging      452

Displaying All Log Information      452

Including Date and Time with Log Data      452

Filtering Log Information      453

Clearing the Log      454

Redirecting Log Output to a File      454

Accessing the Secondary Logs      455

Controlling the Backup Service      455

Forcing Backup Operations      455

Forcing Restore Operations      456

Wiping Archived Data      456

Generating Bug Reports      456

Using the Shell to Inspect SQLite Databases      456

Using the Shell to Stress Test Applications      456

Letting the Monkey Loose on Your Application      457

Listening to Your Monkey      457

Directing Your Monkey’s Actions      457

Training Your Monkey to Repeat His Tricks      459

Keeping the Monkey on a Leash      459

Learning More About Your Monkey      459

Installing Custom Binaries via the Shell      459

Appendix B: The SQLite Quick-Start Guide      463

Exploring Common Tasks with SQLite      463

Using the sqlite3 Command-Line Interface      464

Launching the ADB Shell      464

Connecting to a SQLite Database      464

Exploring Your Database      465

Importing and Exporting the Database and Its Data      466

Executing SQL Commands on the Command Line      468

Using Other sqlite3 Commands      469

Understanding SQLite Limitations      469

Learning by Example: A Student Grade Database      469

Designing the Student Grade Database Schema      470

Creating Simple Tables with AUTOINCREMENT      470

Inserting Data into Tables      471

Querying Tables for Results with SELECT      471

Using Foreign Keys and Composite Primary Keys      472

Altering and Updating Data in Tables      473

Querying Multiple Tables Using JOIN      474

Using Calculated Columns      474

Using Subqueries for Calculated Columns      476

Deleting Tables      476

Index    477

Erscheint lt. Verlag 9.8.2012
Verlagsort New Jersey
Sprache englisch
Maße 227 x 179 mm
Gewicht 810 g
Themenwelt Informatik Software Entwicklung Mobile- / App-Entwicklung
Mathematik / Informatik Informatik Web / Internet
Informatik Weitere Themen Smartphones / Tablets
Technik Nachrichtentechnik
ISBN-10 0-321-81384-7 / 0321813847
ISBN-13 978-0-321-81384-8 / 9780321813848
Zustand Neuware
Haben Sie eine Frage zum Produkt?
Mehr entdecken
aus dem Bereich
Das umfassende Handbuch

von Jürgen Sieben

Buch | Hardcover (2023)
Rheinwerk (Verlag)
89,90
Das große Handbuch zum JavaScript-Framework

von Christoph Höller

Buch | Hardcover (2022)
Rheinwerk (Verlag)
39,90