Ian F. Darwin has worked in the computer industry for three decades. He wrote the freeware file(1) command used on Linux and BSD and is the author of Checking C Programs with Lint, Java Cookbook, and over seventy articles and courses on C and Unix. In addition to programming and consulting, Ian teaches Unix, C, and Java for Learning Tree International, one of the world’s largest technical training companies.
Table of Contents
Chapter 1 Getting Started
- Introduction: Getting Started
- Learning the Java Language
- Creating a “Hello, World” Application from the Command Line
- Creating a “Hello, World” Application in Eclipse
- Setting Up an IDE on Windows to Develop for Android
- Understanding the Android Life Cycle
- Installing .apk Files onto an Emulator via the ADB
- Installing Apps onto an Emulator via SlideME
- Sharing Java Classes from Another Eclipse Project
- Referencing Libraries to Implement External Functionality
- Using SDK Samples to Help Avoid Head Scratching
- Keeping the Android SDK Updated
- Taking a Screenshot from the Emulator/Android Device
- Program: A Simple CountDownTimer Example
- Program: Tipster, a Tip Calculator for the Android OS
Chapter 2 Designing a Successful Application
- Introduction: Designing a Successful Android Application
- Exception Handling
- Accessing Android’s Application Object as a “Singleton”
- Keeping Data When the User Rotates the Device
- Monitoring the Battery Level of an Android Device
- Creating Splash Screens in Android
- Designing a Conference/Camp/Hackathon/Institution App
- Using Google Analytics in an Android Application
- A Simple Torch/Flashlight
- Adapting an Android Phone Application to Be Used on a Tablet
- Setting First-Run Preferences
- Formatting the Time and Date for Display
- Controlling Input with KeyListeners
- Backing Up Android Application Data
- Using Hints Instead of Tool Tips
Chapter 3 Testing
- Introduction: Testing
- Doing Test-Driven Development (TDD) in Android
- Setting Up an Android Virtual Device (AVD) for App Testing
- Testing on a Huge Range of Devices with Cloud-based Testing
- Creating and Using a Test Project
- Troubleshooting Application Crashes
- Debugging Using Log.d and LogCat
- Getting Bug Reports from Users Automatically with BugSense
- Using a Local Runtime Application Log for Analysis of Field Errors or Situations
- Reproducing Activity Life-Cycle Scenarios for Testing
- Keeping Your App Snappy with StrictMode
- Running the Monkey Program
- Sending Text Messages and Placing Calls Between AVDs
Chapter 4 Inter-/Intra-Process Communication
- Introduction: Inter-/Intra-Process Communication
- Opening a Web Page, Phone Number, or Anything Else with an Intent
- Emailing Text from a View
- Sending an Email with Attachments
- Pushing String Values Using Intent.putExtra()
- Retrieving Data from a Subactivity Back to Your Main Activity
- Keeping a Service Running While Other Apps Are on Display
- Sending/Receiving a Broadcast Message
- Starting a Service After Device Reboot
- Creating a Responsive Application Using Threads
- Using AsyncTask to Do Background Processing
- Sending Messages Between Threads Using an Activity Thread Queue and Handler
- Creating an Android Epoch HTML/JavaScript Calendar
Chapter 5 Content Providers
- Introduction: Content Providers
- Retrieving Data from a Content Provider
- Writing a Content Provider
- Writing an Android Remote Service
Chapter 6 Graphics
- Introduction: Graphics
- Using a Custom Font
- Drawing a Spinning Cube with OpenGL ES
- Adding Controls to the OpenGL Spinning Cube
- Freehand Drawing Smooth Curves
- Taking a Picture Using an Intent
- Taking a Picture Using android.media.Camera
- Scanning a Barcode or QR Code with the Google ZXing Barcode Scanner
- Using AndroidPlot to Display Charts and Graphs
- Using Inkscape to Create an Android Launcher Icon
- Creating Easy Launcher Icons from OpenClipArt.org Using Paint.NET
- Using Nine Patch Files
- Creating HTML5 Charts with Android RGraph
- Adding a Simple Raster Animation
- Using Pinch to Zoom
Chapter 7 Graphical User Interface
- Introduction: GUI
- Understanding and Following User Interface Guidelines
- Handling Configuration Changes by Decoupling the View from the Model
- Creating a Button and Its Click Event Listener
- Wiring Up an Event Listener in Five Different Ways
- Using CheckBoxes and RadioButtons
- Enhancing UI Design Using Image Buttons
- Offering a Drop-Down Chooser via the Spinner Class
- Handling Long-Press/Long-Click Events
- Displaying Text Fields with TextView and EditText
- Constraining EditText Values with Attributes and the TextWatcher Interface
- Implementing AutoCompleteTextView
- Feeding AutoCompleteTextView Using an SQLite Database Query
- Turning Edit Fields into Password Fields
- Changing the Enter Key to “Next” on the Soft Keyboard
- Processing Key-Press Events in an Activity
- Let Them See Stars: Using RatingBar
- Making a View Shake
- Providing Haptic Feedback
- Navigating Different Activities Within a TabView
- Creating a Custom Title Bar
- Formatting Numbers
- Formatting with Correct Plurals
- Starting a Second Screen from the First
- Creating a Loading Screen That Will Appear Between Two Activities
- Using SlidingDrawer to Overlap Other Components
- Customizing the SlidingDrawer Component to Animate/Transition from the Top Down
- Adding a Border with Rounded Corners to a Layout
- Detecting Gestures in Android
- Building a UI Using Android 3.0 Fragments in Android 1.6 and Later
- Using the Android 3.0 Photo Gallery
- Creating a Simple App Widget
Chapter 8 GUI Alerts: Menus, Dialogs, Toasts, and Notifications
- Introduction: GUI Alerts
- Creating and Displaying a Menu
- Handling Choice Selection in a Menu
- Creating a Submenu
- Creating a Pop-up/Alert Dialog
- Using a Timepicker Widget
- Creating an iPhone-like Wheel Picker for Selection
- Creating a Tabbed Dialog
- Creating a ProgressDialog
- Creating a Custom Dialog with Buttons, Images, and Text
- Creating a Reusable About Box Class
- Customizing the Appearance of a Toast
- Creating a Notification in the Status Bar
Chapter 9 GUI: List View
- Introduction: ListView
- Building List-Based Applications with ListView
- Creating a “No Data” View for ListViews
- Creating an Advanced ListView with Images and Text
- Using Section Headers in ListViews
- Keeping the ListView with the User’s Focus
- Writing a Custom List Adapter
- Handling Orientation Changes: From ListView Data Values to Landscape Charting
Chapter 10 Multimedia
- Introduction: Multimedia
- Playing a YouTube Video
- Using the Gallery with the ImageSwitcher View
- Capturing Video Using MediaRecorder
- Using Android’s Face Detection Capability
- Playing Audio from a File
- Playing Audio Without Interaction
- Using Speech to Text
- Making the Device Speak with Text-to-Speech
Chapter 11 Data Persistence
- Introduction: Data Persistence
- Getting File Information
- Reading a File Shipped with the App Rather Than in the Filesystem
- Listing a Directory
- Getting Total and Free Space Information About the SD Card
- Providing User Preference Activity with Minimal Effort
- Checking the Consistency of Default Shared Preferences
- Performing Advanced Text Searches
- Creating an SQLite Database in an Android Application
- Inserting Values into an SQLite Database
- Loading Values from an Existing SQLite Database
- Working with Dates in SQLite
- Parsing JSON Using JSONObject
- Parsing an XML Document Using the DOM API
- Parsing an XML Document Using an XmlPullParser
- Adding a Contact
- Reading Contact Data
Chapter 12 Telephone Applications
- Introduction: Telephone Applications
- Doing Something When the Phone Rings
- Processing Outgoing Phone Calls
- Dialing the Phone
- Sending Single-Part or Multipart SMS Messages
- Receiving an SMS Message in an Android Application
- Using Emulator Controls to Send SMS Messages to the Emulator
- Using Android’s TelephonyManager to Obtain Device Information
Chapter 13 Networked Applications
- Introduction: Networking
- Using a RESTful Web Service
- Extracting Information from Unstructured Text Using Regular Expressions
- Parsing RSS/Atom Feeds Using ROME
- Using MD5 to Digest Clear Text
- Converting Text into Hyperlinks
- Accessing a Web Page Using WebView
- Customizing a WebView
Chapter 14 Gaming and Animation
- Introduction: Gaming and Animation
- Building an Android Game Using flixel-android
- Building an Android Game Using AndEngine (Android-Engine)
- Processing Timed Keyboard Input
Chapter 15 Social Networking
- Introduction: Social Networking
- Integrating Social Networking Using HTTP
- Loading a User’s Twitter Timeline Using JSON
Chapter 16 Location and Map Applications
- Introduction: Location-Aware Applications
- Getting Location Information
- Accessing GPS Information in Your Application
- Mocking GPS Coordinates on a Device
- Using Geocoding and Reverse Geocoding
- Getting Ready for Google Maps Development
- Adding a Device’s Current Location to Google Maps
- Drawing a Location Marker on a Google MapView
- Drawing Multiple Location Markers on a MapView
- Creating Overlays for a Google MapView
- Changing Modes of a Google MapView
- Drawing an Overlay Icon Without Using a Drawable
- Implementing Location Search on Google Maps
- Placing a MapView Inside a TabView
- Handling a Long-Press in a MapView
- Using OpenStreetMap
- Creating Overlays in OpenStreetMap Maps
- Using a Scale on an OpenStreetMap Map
- Handling Touch Events on an OpenStreetMap Overlay
- Getting Location Updates with OpenStreetMap Maps
Chapter 17 Accelerometer
- Introduction: Sensors
- Checking for the Presence or Absence of a Sensor
- Using the Accelerometer to Detect Shaking of the Device
- Checking Whether a Device Is Facing Up or Facing Down Based on Screen Orientation Using an Accelerometer
- Finding the Orientation of an Android Device Using an Orientation Sensor
- Reading the Temperature Sensor
Chapter 18 Bluetooth
- Introduction: Bluetooth
- Enabling Bluetooth and Making the Device Discoverable
- Connecting to a Bluetooth-Enabled Device
- Listening for and Accepting Bluetooth Connection Requests
- Implementing Bluetooth Device Discovery
Chapter 19 System and Device Control
- Introduction: System and Device Control
- Accessing Phone Network/Connectivity Information
- Obtaining Information from the Manifest File
- Changing Incoming Call Notification to Silent, Vibrate, or Normal
- Copying Text and Getting Text from the Clipboard
- Using LED-Based Notifications
- Making the Device Vibrate
- Running Shell Commands from Your Application
- Determining Whether a Given Application Is Running
Chapter 20 Other Programming Languages and Frameworks
- Introduction: Other Programming Languages
- Running an External/Native Unix/Linux Command
- Running Native C/C++ Code with JNI on the NDK
- Getting Started with the Scripting Layer for Android (SL4A, Formerly Android Scripting Environment)
- Creating Alerts in SL4A
- Fetching Your Google Documents and Displaying Them in a ListView Using SL4A
- Sharing SL4A Scripts in QR Codes
- Using Native Handset Functionality from WebView via JavaScript
- Creating a Platform-Independent Application Using PhoneGap/Cordova
Chapter 21 Strings and Internationalization
- Introduction: Internationalization
- Internationalizing Application Text
- Finding and Translating Strings
- Handling the Nuances of strings.xml
Chapter 22 Packaging, Deploying, and Distributing/Selling Your App
- Introduction: Packaging, Deploying, and Distributing
- Creating a Signing Certificate
- Signing Your Application
- Distributing Your Application via Android Play (formerly the Android Market)
- Integrating AdMob into Your App
- Obfuscating and Optimizing with ProGuard
- Providing a Link to Other Published Apps in the Google Play Market
- Colophon