contents


preface
acknowledgments
about this book
about the cover illustration

Part 1 Background and fundamentals

1 Introducing Android
1.1 Android in a nutshell
1.2 Hello Android!
1.3 Java, but not Java Java
1.4 Linux, but not Linux Linux
1.5 More capabilities with native libraries
1.6 Tools of the trade
1.7 Summary
2 Android application fundamentals
2.1 The DealDroid application
2.2 Core building blocks
2.3 Application manifest
2.4 Resources
2.5 Layout, views, and widgets
2.6 Activities
2.7 Adapters
2.8 Intents and IntentFilters
2.9 The Application object
2.10 Summary
3 Managing lifecycle and state
3.1 Defining an Android application
3.2 Knowing the Activity lifecycle
3.3 Controlling Activity instance state
3.4 Getting things done within a task
3.5 Summary

Part 2 Real world recipes

4 Getting the pixels perfect
4.1 The MyMovies application
4.2 View hierarchies and rendering
4.3 Arranging views in layouts
Technique 1 The merge and include directives
4.4 Expanding on ListView and Adapter
Technique 2 Managing a stateful list
Technique 3 Header and footer views
4.5 Applying themes and styles
Technique 4 Applying and writing styles
Technique 5 Applying and writing themes
Technique 6 Styling ListView backgrounds
4.6 Working with drawables
Technique 7 Working with shape drawables
Technique 8 Working with selector drawables
Technique 9 Scaling views with nine-patch drawables
4.7 Creating portable user interfaces
Technique 10 Automatically scaling to different screens
Technique 11 Loading configuration dependent resources
Technique 12 Programming pixel-independently
4.8 Summary
5 Managing background tasks with Services
5.1 It’s all about the multitasking
5.2 Why services and how to use them
Technique 13 Creating a Service
Technique 14 Starting a Service automatically
Technique 15 Communicating with a Service
Technique 16 Using a Service for caching data
Technique 17 Creating notifications
5.3 Scheduling and Services
Technique 18 Using the AlarmManager
Technique 19 Keeping Services awake
Technique 20 Using Cloud to Device Messaging
5.4 Summary
6 Threads and concurrency
6.1 Concurrency in Android
Technique 21 Basic threading
Technique 22 Communicating change between threads
Technique 23 Managing threads in thread pools
6.3 Working with AsyncTask
Technique 24 Implementing jobs with AsyncTask
Technique 250 Preparing for configuration changes
6.4 Miscellaneous techniques
Technique 26 Displaying splash screens with timers
Technique 27 Implementing custom message loops
6.5 Summary
7 Storing data locally
7.1 Reading and writing files
Technique 28 Using internal storage
Technique 29 Using external storage
Technique 30 Using cache directories
Technique 31 Making sure files are saved with sync
7.2 Maintaining preferences
Technique 32 Reading and writing preference data
Technique 33 Using a PreferenceActivity
7.3 Working with a database
Technique 34 Creating a database and model objects
Technique 35 Creating DAOs and a data manager
7.4 Inspecting SQLite databases
7.5 Summary
8 Sharing data between apps
8.1 Process-to-process sharing
Technique 36 Using Intents
Technique 37 Making remote procedure calls
Technique 38 Share data (and more) by sharing Context
8.2 Accessing common data
Technique 39 Using standard ContentProviders
Technique 40 Working with a custom ContentProvider
8.3 Summary
9 HTTP networking and web services
9.1 Basic HTTP networking
Technique 41 HTTP with HttpURLConnection
Technique 42 HTTP with Apache HttpClient
Technique 43 Configuring a thread-safe HttpClient
9.2 Consuming XML and JSON web services
Technique 44 Parsing XML with SAX
Technique 45 Parsing XML with XmlPull
Technique 46 Parsing JSON
9.3 How to gracefully recover from network failures
Technique 47 Retrying requests using request-retry handlers
Technique 48 Handling network configuration changes
9.4 Summary
10 Location is everything
10.1 A brief introduction to geospatial coordinates
10.2 Location managers, providers, and listeners
Technique 49 Checking the status of a LocationProvider
Technique 50 Determining current location with a LocationListener
10.3 Building a map-based application
Technique 51 Converting an address to geographical coordinates
Technique 52 Creating a MapActivity with associated MapView
Technique 53 Displaying OverlayItems on a MapView
10.4 Summary
11 Appeal to the senses using multimedia
11.1 Features too good for a feature phone
Technique 54 Detecting capabilities
11.2 Managing media
Technique 55 Working with resources and files
Technique 56 Using media ContentProviders
Technique 57 Using Intents and Activities
11.3 Media playback
Technique 58 Images and simple animations
Technique 59 Controlling audio
Technique 60 Watching video
11.4 Capturing input
Technique 61 Taking pictures
Technique 62 Recording audio and video
11.5 Summary
12 2D and 3D drawing
12.1 Drawing with the 2D libraries
Technique 63 Going full screen
Technique 64 Drawing simple shapes
Technique 65 Rendering continuously in the UI thread
Technique 66 Drawing text to the screen
Technique 67 Using a typeface when drawing text
Technique 68 Displaying bitmaps
Technique 69 Applying 2D effects
12.2 3D and OpenGL ES
Technique 70 Drawing the first triangle
Technique 71 Creating a pyramid
Technique 72 Coloring the pyramid
Technique 73 Adding texture to the pyramid
12.3 Summary

Part 3 Beyond standard development

13 Testing and instrumentation
13.1 Testing the Android
Technique 74 A simple Android unit test
13.2 Pulling strings: Android instrumentation
Technique 75 Unit testing Activities
Technique 76 User stories as functional tests
Technique 77 Beautiful tests with Robotium
13.3 Beyond instrumentation: mocks and monkeys
Technique 78 Mock objects and how to use them
Technique 79 Accelerating unit tests with Robolectric
Technique 80 Stressing out with the Monkey
13.4 Summary
14 Build management
14.1 Building Android applications
Technique 81 Building with Ant
14.2 Managing builds with Maven
Technique 82 Building with Maven
Technique 83 The Maven Eclipse plugin
Technique 84 The Maven/Android SDK deployer
14.3 Build servers and continuous builds
Technique 85 Continuous builds with Hudson
Technique 86 Matrix builds
14.4 Summary
15 Developing for Android tablets
15.1 Tablet prep
Technique 87 Leveraging existing code using library projects
Technique 88 Targeting only tablets
15.2 Tablet fundamentals
Technique 89 Fragments
Technique 90 The Action Bar
Technique 91 Drag and Drop
15.3 Summary

 
appendix A Debugging tools of the trade
appendix B Extending Android development
appendix C ProGuard
appendix D monkeyrunner
index