Preface
If you come to this book after having read its companion volumes, The
Busy Coder's Guide to Android Development and The Busy Coder's Guide to
Advanced Android Development, thanks for sticking with the series!
CommonsWare aims to have the most comprehensive set of Android
development resources (outside of the Open Handset Alliance itself), and
we appreciate your interest.
If you come to this book having learned about Android from other sources,
thanks for joining the CommonsWare community!
Table of Contents
Welcome to the Warescription!. ...........xiii
Preface. ............xv
Welcome to the Book!............xv
Prerequisites............xv
Using the Tutorials..........xvi
Warescription. ......xviii
What's New............xviii
About the "Further Reading" Sections.......xix
Errata and Book Bug Bounty. ...........xix
Source Code License.........xx
Creative Commons and the Four-to-Free (42F) Guarantee.........xxi
Lifecycle of a CommonsWare Book.........xxi
Roster of Tutorials.......xxii
Your First Android Project
Step #1: Create the New Project
Step #1: Eclipse
Step #2: Command Line
Step #2: Build, Install, and Run the Application in Your Emulator or Device
Step #1: Eclipse. ...................6
Step #2: Command Line. ......7
A Simple Form
Step-By-Step Instructions
Step #1: Generate the Application Skeleton
Step #2: Modify the Layout
Step #3: Support All Screen Sizes
Step #4: Compile and Install the Application
Step #5: Run the Application in the Emulator
Step #6: Create a Model Class
Step #7: Save the Form to the Model
Extra Credit..........18
Further Reading. ........18
A Fancier Form
Step-By-Step Instructions
Step #1: Switch to a TableLayout
Step #2: Add a RadioGroup
Step #3: Update the Model
Step #4: Save the Type to the Model
Extra Credit........26
Further Reading. ........27
Adding a List
Step-By-Step Instructions
Step #1: Hold a List of Restaurants
Step #2: Save Adds to List
Step #3: Implement toString()
Step #4: Add a ListView Widget
Step #5: Build and Attach the Adapter
Extra Credit. ...........35
Further Reading........36
Making Our List Be Fancy
Step-By-Step Instructions
Step #1: Create a Stub Custom Adapter
Step #2: Design Our Row
Step #3: Override getView(): The Simple Way
Step #4: Create a RestaurantHolder
Step #5: Recycle Rows via RestaurantHolder
Extra Credit. ...........45
Further Reading...........45
Splitting the Tab
Step-By-Step Instructions
Step #1: Rework the Layout
Step #2: Wire In the Tabs
Step #3: Get Control On List Events
Step #4: Update Our Restaurant Form On Clicks
Step #5: Switch Tabs On Clicks
Extra Credit.............56
Further Reading.............56
Menus and Messages
Step-By-Step Instructions
Step #1: Add Notes to the Restaurant
Step #2: Add Notes to the Detail Form
Step #3: Define the Option Menu
Step #4: Show the Notes as a Toast
Extra Credit. .........67
Further Reading.......67
Sitting in the Background
Step-By-Step Instructions
Step #1: Initialize the Progress Bar
Step #2: Create the Work Method
Step #3: Fork the Thread from the Menu
Step #4: Manage the Progress Bar
Extra Credit. ..........75
Further Reading....76
Life and Times
Step-By-Step Instructions
Step #1: Lengthen the Background Work
Step #2: Pause in onPause()
Step #3: Resume in onResume()
Extra Credit............86
Further Reading........86
A Few Good Resources
Step-By-Step Instructions
Step #1: Review our Current Resources
Step #2: Create a Landscape Layout
Extra Credit....................91
Further Reading.........92
The Restaurant Store
Step-By-Step Instructions
Step #1: Create a Stub SQLiteOpenHelper
Step #2: Manage our Schema
Step #3: Remove Extraneous Code from LunchList
Step #4: Get Access to the Helper
Step #5: Save a Restaurant to the Database
Step #6: Get the List of Restaurants from the Database
Step #8: Clean Up Lingering ArrayList References
Step #9: Refresh Our List
Extra Credit...............................106
Further Reading..............................107
Getting More Active
Step-By-Step Instructions
Step #1: Create a Stub Activity
Step #2: Launch the Stub Activity on List Click
Step #3: Move the Detail Form UI
Step #4: Clean Up the Original UI
Step #5: Pass the Restaurant _ID
Step #6: Load the Restaurant Into the Form
Step #7: Add an "Add" Menu Option
Step #8: Detail Form Supports Add and Edit
Extra Credit. .................132
Further Reading................133
What's Your Preference?
Step-By-Step Instructions
Step #1: Define the Preference XML
Step #2: Create the Preference Activity
Step #3: Connect the Preference Activity to the Option Menu
Step #4: Apply the Sort Order on Startup
Step #5: Listen for Preference Changes
Step #6: Re-Apply the Sort Order on Changes
Extra Credit.................144
Further Reading..............145
Turn, Turn, Turn
Step-By-Step Instructions
Step #1: Add a Stub onSaveInstanceState()
Step #2: Pour the Form Into the Bundle
Step #3: Repopulate the Form
Step #4: Fix Up the Landscape Detail Form
Extra Credit...................150
Further Reading. ............151
Feeding at Lunch
Step-By-Step Instructions
Step #1: Add a Feed URL to the Data Model
Step #2: Update the Detail Form
Step #3: Add a Feed Options Menu Item
Step #4: Add Permissions and Check Connectivity
Step #5: Install the RSS Library
Step #6: Fetch and Parse the Feed
Step #7: Display the Feed Items
Extra Credit................179
Further Reading. .........180
Serving Up Lunch
Step-By-Step Instructions
Step #1: Create an Register a Stub IntentService
Step #2: Move Feed Fetching and Parsing to the Service
Step #3: Send the Feed to the Activity
Step #4: Display the Feed Items, Redux
Extra Credit.............192
Further Reading......193
Locating Lunch
Step-By-Step Instructions
Step #1: Add Latitude and Longitude to the Data Model
Step #2: Save the Restaurant in onPause()
Step #3: Add a TextView and Options Menu Item for Location
Step #4: Update the Permissions
Step #5: Find Our Location Using GPS
Step #6: Only Enable Options Menu Item If Saved
Extra Credit.................215
Further Reading. .............216
Putting Lunch on the Map
Step-By-Step Instructions
Step #1: Add an Options Menu Item for Map
Step #2: Create and Use a MapActivity
Step #3: Create an ItemizedOverlay
Step #4: Handle Marker Taps
Extra Credit. .......235
Further Reading. ..........236
Is It Lunchtime Yet?
Step-By-Step Instructions
Step #1: Create a TimePreference
Step #2: Collect Alarm Preferences
Step #3: Set Up a Boot-Time Receiver
Step #4: Manage Preference Changes
Step #5: Display the Alarm
Extra Credit. .....257
Further Reading........258
More Subtle Lunch Alarms
Step-By-Step Instructions
Step #1: Collect Alarm Style Preference
Step #2: Display the Alarm, Redux
Extra Credit..................268
Further Reading...............268
How To Get Started
Java
Step #1: Install the JDK
Step #2: Learn Java
Install the Android SDK
Step #1: Install the Base Tools
Step #2: Install the SDKs and Add-Ons
Install the ADT for Eclipse
Install Apache Ant
Set Up the Emulator
Set Up the Device
Step #1: Windows
Step #2: OS X and Linux
Coping with Eclipse
How to Import a Non-Eclipse Project.....291
How to Get To DDMS.......296
How to Create an Emulator.......298
How to Run a Project......299
How Not to Run Your Project. ......300
How to Get Past Eclipse.......300
● Screenshot ●