Contents
Part I: Get Android and Get Coding!
The Fast Path to Learning Android Development
Thinking in a Smartphone Mindset
The Interface Is More Than the Screen
Translating Developer Dreams into Android Action
Getting the Prerequisites for Android
Determining the Right Java for You
Knowing (Enough) Java for Android
Choosing a Development Environment
Option 1: Choosing Android Studio
Option 2: Choosing Eclipse the Quick Way
Options 3: Choosing Eclipse the Do-It-Yourself Way
Completing Your Development Environment Setup
Creating Your First Android Virtual Device
Creating Your First Android Application
Writing Your First Android Code
Chapter 3: Inside Your First Android Project
Looking at Android Project Structure
Benefitting from Generated Components
Picturing What Drawables Can Do For You
Working with Other Key Files in Your Project
Controlling Applications with Android Manifests
Permutating Projects with Properties
Chapter 4: Changing and Enhancing Your Project
Extending Your Application with the Android Manifest
Specifying Target Screen Sizes
Controlling Support for Different Android Versions
Looking Inside Your First Activity
Building and Running Your Enhanced Application
Part II: Activities and the User Interface
Chapter 5: Working with Android Widgets
Understanding Activity Fundamentals
Handling Images with ImageView and ImageButton
CheckBox? Got It
Timing All Manner of Things with Clocks
Views: The Base of All UI Widgets
Useful Common Inherited Properties
Useful Common Inherited Methods
Chapter 6: Layouts and UI Design
Positioning Relative to the Activity Container
Identifiying Properties for Relative Layout
Relative Positioning Properties
Determining the Order of Layout Relationships
Overlapping Widgets in Relative Layouts
Controlling the Five Key Qualifiers for LinearLayout
Understanding Widget Behavior within TableLayout
Layout Manipulation with the Layout Editor
Even More Reasons for XML Layouts
Converting to XML-based Layouts with Java Logic
Attaching Layout Definitions to Java
Chapter 7: Building Layouts with Lists and Adapters
Using Adapters to Populate Options
Making More Sophisticated Lists
Chapter 8: Working with Input Methods, Menus and Dialogs
Using The Input Method Framework
Accessorizing with Soft Keyboards
Forcing the IME out of Existence
Creating Menus for your Application
Generating Traditional Dialog Alerts
Chapter 9: Adopting the Action Bar
Managing Android Versions for Action Bar
Creating Action Bar Applications
Enabling the Action Bar for your Application
Moving Menu Functionality to the Action Bar
Using Java to Manage Action Bars
Working with a Standard Action Bar in Java
Choosing a Tab Layout for the Action Bar
Using Other Layouts for the Action Bar
Chapter 10: The Life of an Activity
Understanding the Activity Lifecycle
Working with Activity Callback Methods
Understanding the Goals of Android Activity Behavior
Working with Activity Configuration Changes
Understanding the Default Configuration Change Approach
Part III: A World of Wonderful Devices and Screens
Introducing the Fragment Class
Backwards Compatibility with Fragments
Designing with Fragments in Mind
Introducing the Fragment Lifecycle
Understanding Fragment Lifecycle Callback Methods
Keeping Sane with Fragment Lifecycles
Implementing Your Own Fragment-Based Application
Creating Layouts for the Fragments Examples
Controlling Which Layout Is Chosen
Coding Differences for Fragments
Seeing Differing Fragment Behavior in Action
Chapter 12: Intents and Receivers
Intent Actions for all Kinds of Purposes
Adding Intents to Your Manifest
Seeing Intent-launched Activities in Action
Deciding on Activity Dependency
Starting the Intent-Invoked Activity
Using Receivers When No UI is Needed
Navigating Receiver Limitations
Chapter 13: Making Phone Calls
Checking for Phones and “Phonies”
Chapter 14: Making Noise with Audio for Android
Building Your First Audio Application
Coding for Audio Playback Using the Media Framework
Starting With A Simple Audio Player Layout
Coding the AudioExample Behavior
Building Your Own Android Music Streaming Application
Synchronous versus Asynchronous Playback
Alternative Audio Playback Approaches
Using SoundPool for Simultaneous Playback
Going Fully-Asynchronous with AsyncPlayer
Making Recordings with MediaRecorder
Chapter 15: Locations and Mapping with Android
Choosing Map Providers for Your Application
Preparing for Google Maps Development
Enabling a Maps API on Your Google API Project
Building Your First Maps Application
Using MapActivity or FragmentActivity with MapView
Permissions and Manifest Settings for Maps
Building the Layout for Your Map Application
Adding Flair and Features to Your Maps
Toolbars and theMy Location Button
Listeners for Every Conceivable Type of Map Interaction
Part IV: Working with Resources and Services
Chapter 16: Weaving the Web with Android
Working with the WebView Widget
Creating a Simple Application with a WebView
Simple and Not-So-Simple WebView Security
Building HTML Layouts with WebView
UI-less Internet Interaction with Android
Why Multiple Approaches to Web Interaction?
Building a JSON-based Application with HttpURLConnection
Troubleshooting Issues with Internet Connections
Mastering Downloads with DownloadManager
Introducing the DownloadManager System Service
Selecting Permissions for DownloadManager Use
Coding DownloadManager Behavior
Dealing with Download Problems
Chapter 17: Working with Files
Using Raw and Asset-based Files
Populating Lists from Resource Files
Working with Files from the File System
Permissions for Reading and Writing Files
Examining External Files in Action
Seeing File Save and Read Behavior in Action
Ensuring External Storage Is Available When Needed
Other Considerations with Android File Systems
Android Filesystems Throughout History
Controlling UI Delays with File I/O
Chapter 18: Managing Databases with Android
SQLite: A Seriously Popular Database
Creating SQLite Databases for Your Application
Introducing the SQLiteExample Application
Building a Database-Driven Activity
Choosing Query Approaches for SQLite and Android
Managing Data Results with Cursors
Modifying Data with Your Android Application
Tracking SQLite Versions and Android Versions
Packaging and Managing SQLite Databases for Android
Managing Performance and Android Storage
Packaging Your Own SQLite Database with Your Application
Preparing SQLite Databases for Packaging
Working with Preference-Specific Activities and Fragments
Seeing the Big Picture with Preferences
Using Preference and Preference Header Resources
Filling in the Blanks with PreferenceFragment
Bringing the Preference Puzzle Pieces Together
Other Preference Considerations
Nesting Preferences and Display Quirks
Using the Old-School Approach to Preferences
Adapting PreferenceActivty for Older Behavior
Chapter 20: Android Security and Permissions
Requesting Permissions for Your Application
Dealing with Debugging Permissions
Installing Applications and Accepting Permissions
Securing Applications for Publication and Execution
Securing Your Application with Certificate Signing
Signing Is (Almost) Forever, So Take Care
Protecting Android and Applications at Runtime
Chapter 21: Incorporating External Libraries with Android
Choosing Library Sources or JARs
Considering Java Performance for Android
Adapting an Application to Use an External Library
Sourcing Apache Commons IOUtils
Adding the JAR to Your Project’s Libraries
Referencing (or Refactoring for) Your External Libraries
Scripting Layer for Android Overview
Choosing Your Approach to SL4A
Chapter 22: Leveraging Android Services
Implementing Your Own Service Class
Controlling Service Lifecycle via Callbacks
Adding Manifest Entries for Your Service
Client-to-Service Communication
Service-to-Client Communication
Implementing the Java Logic for Our Service
Creating an Example Client for the Service
Chapter 23: Communicating with Notifications
Customizing the Notification Object
Adding Icons for Notifications
Notifications as the User Experiences Them
Using the Builder Approach to Notifications
Other Uses and Extensions to Notifications
More Advanced Notification Features
More Embedded Actions in Notifications