SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
Learning Android™ Application Programming will help you master modern Android programming by building a fully functional app from the ground up. Working with the Android 4.3 toolset, you’ll solve real-world problems faced by every Android developer and learn best practices for success with any mobile development project.
Ideal for developers who have little or no Android experience but have basic Java experience, this tutorial teaches through carefully structured exercises that address the entire development process. Leading Android developers James Talbot and Justin McLean guide you through building a real biking mobile app that can handle everything from mileage tracking to route planning. Each chapter builds your knowledge, step-by-step, and in the end you will have a complete, working app.
Along the way, you’ll gain hands-on experience with writing code that can run on the widest spectrum of devices while still leveraging Android’s newest features. You’ll also discover proven solutions for the occasionally messy realities of Android development, from inaccurate sensor data to inadequate device battery life–pitfalls that most other Android books ignore.
Learn how to
Get all of this book’s sample code at www.androiddevbook.com/code.html.
Register your book at informit.com/register to gain access to the Bonus KitKat Chapter.
Download the free version of this book’s On Your Bike app from Google Play today.
Learning Android Application Programming: Creating an Android User Interface
Download the sample pages (includes Chapter 4 and Index)
Preface xix
Acknowledgments xxi
About the Authors xxiii
Chapter 1: An Introduction to Android Development 1
Understanding the Android Difference 2
Building Native Applications 2
Understanding the History of Android 3
Using the Android User Interface 8
Understanding Android Applications 10
Introducing Google Play 10
Summary 12
Chapter 2: Kicking the Tires: Setting Up Your Development Environment 13
Installing the Java JDK and JRE on Windows 14
Installing the Eclipse IDE on Windows 16
Installing the Android SDK on Windows 19
Installing and Using Java on a Mac 24
Summary 27
Chapter 3: Putting On the Training Wheels: Creating Your First Android Application 29
Creating an Android Application 29
Running Your Android Project 32
Working with Lint in an Android Project 37
Understanding the Android Project Files 37
Summary 50
Chapter 4: Going for Your First Ride: Creating an Android User Interface 51
Refactoring Your Code 51
Implementing Strict Mode 54
Creating a Simple User Interface 55
Understanding the Activity Lifecycle 68
Making an Android Device Vibrate 72
Saving User Preferences 74
Summary 80
Chapter 5: Customizing Your Bike: Improving Android Application Usability 81
Refactoring Your Code 82
Improving the Setting Activity 88
Action Bars and Menus 94
Using Notifications 101
Creating a Database 107
Summary 122
Chapter 6: Pimping Your Bike: Styling an Android Application 125
Refactoring Your Application 126
Understanding Screen Differences 126
Making Your Application Resolution Independent 129
Using Configuration Qualifiers 132
Using Styles and Themes 149
Summary 162
Chapter 7: Are We There Yet? Making Your Application Location Aware 165
Refactoring Your Code 165
Finding the Device’s Location 169
Dealing with Inaccurate Location Data 190
Storing GPS Data 196
Displaying GPS Data 209
Summary 220
Chapter 8: Inviting Friends for a Ride: Social Network Integration 223
Refactoring Your Code 223
Integrating Photos into an Android Application 224
Sharing Content with Friends 242
Summary 248
Chapter 9: Tuning Your Bike: Optimizing Performance, Memory, and Power 249
Refactoring Your Code 249
Running Your Application as a Service 250
Improving Battery Life 267
Speeding Up Databases 278
Summary 284
Chapter 10: Taking Off the Training Wheels: Testing Your Application 285
Refactoring Your Code 285
Testing with JUnit 286
Testing with Android JUnit Extensions 299
Testing Services 310
Using Monkey Testing 313
Running Tests Automatically 316
Testing on a Wide Range of Devices 323
Summary 325
Chapter 11: Touring France: Optimizing for Various Devices and Countries 327
Refactoring Your Code 327
Going International 329
Accommodating Various Dialects 342
Handling Various Language Formats 344
Enabling Backward Compatibility 348
Building for Various Screen Sizes 352
Using Fragments 355
Summary 361
Chapter 12: Selling Your Bike: Using Google Play and the Amazon Appstore 363
Building Your Media Strategy 363
Employing Advertising in Your Application 369
Using the Amazon Appstore 373
Summary 376
Index 377