What’s New in the Fourth Edition?
Downloading and Installing Android Studio
Downloading Earlier SDK Versions
1. Your First Android Application
From Layout XML to View Objects
For the More Curious: The Android Build Process
Challenge: Customizing the Toast
2. Android and Model-View-Controller
Model-View-Controller and Android
Challenge: Add a Listener to the TextView
Challenge: Add a Previous Button
Challenge: From Button to ImageButton
Activity States and Lifecycle Callbacks
Logging the Activity Lifecycle
Exploring How the Activity Lifecycle Responds to User Actions
Temporarily leaving an activity
Device Configuration Changes and the Activity Lifecycle
For the More Curious: UI Updates and Multi-Window Mode
For the More Curious: Log Levels
Challenge: Preventing Repeat Answers
Including the ViewModel Dependency
ViewModel lifecycle and ViewModelProvider
Saving Data Across Process Death
Overriding onSaveInstanceState(Bundle)
Saved instance state and activity records
ViewModel vs Saved Instance State
For the More Curious: Jetpack, AndroidX, and Architecture Components
For the More Curious: Avoiding a Half-Baked Solution
Challenge: Exploring the Layout Inspector
Challenge: Exploring the Profiler
Declaring activities in the manifest
Adding a cheat button to MainActivity
Passing Data Between Activities
Getting a result back from a child activity
How Android Sees Your Activities
Challenge: Closing Loopholes for Cheaters
Challenge: Tracking Cheat Status by Question
7. Android SDK Versions and Compatibility
Compatibility and Android Programming
Adding code from later APIs safely
Using the Android Developer Documentation
Challenge: Reporting the Device’s Android Version
8. UI Fragments and the Fragment Manager
Defining CrimeFragment’s layout
Creating the CrimeFragment class
Adding a UI fragment to the FragmentManager
Application Architecture with Fragments
Deciding whether to use fragments
9. Displaying Lists with RecyclerView
Adding a New Fragment and ViewModel
ViewModel lifecycle with fragments
Implementing an Adapter to Populate the RecyclerView
Setting the RecyclerView’s adapter
Cleaning Up Binding List Items
For the More Curious: ListView and GridView
Challenge: RecyclerView ViewTypes
10. Creating User Interfaces with Layouts and Widgets
Introducing the Graphical Layout Editor
ConstraintLayout’s inner workings
Styles, themes, and theme attributes
For the More Curious: Margins vs Padding
For the More Curious: New Developments in ConstraintLayout
Challenge: Formatting the Date
11. Databases and the Room Library
Room Architecture Component Library
Accessing the Database Using the Repository Pattern
Challenge: Addressing the Schema Warning
For the More Curious: Singletons
Single Activity: Fragment Boss
Attaching arguments to a fragment
Using LiveData Transformations
Tying database writes to the fragment lifecycle
For the More Curious: Why Use Fragment Arguments?
For the More Curious: Navigation Architecture Component Library
Challenge: Efficient RecyclerView Reloading
Passing Data Between Two Fragments
Passing data to DatePickerFragment
Returning data to CrimeFragment
Using the Android Asset Studio
For the More Curious: App Bar vs Action Bar vs Toolbar
For the More Curious: Accessing the AppCompat App Bar
Challenge: An Empty View for the RecyclerView
Adding a Suspect to the Model Layer
Checking for responding activities
Challenge: Another Implicit Intent
16. Taking Pictures with Intents
Designating a picture location
Scaling and Displaying Bitmaps
Challenge: Efficient Thumbnail Load
Checking string coverage using the Translations Editor
Prioritizing alternative resources
Finding the best-matching resources
For the More Curious: More on Determining Device Size
Making Non-Text Elements Readable by TalkBack
Creating a Comparable Experience
For the More Curious: Using Accessibility Scanner
Challenge: Providing Enough Context for Data Entry
Different Architectures: Why Bother?
MVVM View Models vs Jetpack ViewModels
Implementing Simple Data Binding
For the More Curious: More About Data Binding
For the More Curious: LiveData and Data Binding
20. Unit Testing and Audio Playback
For the More Curious: Integration Testing
For the More Curious: Mocks and Testing
Challenge: Playback Speed Control
Challenge: Play Sound Across Rotation
For the More Curious: More on Style Inheritance
For the More Curious: Accessing Theme Attributes
For the More Curious: Why Bother with XML Drawables?
For the More Curious: Mipmap Images
For the More Curious: 9-Patch Images
23. More About Intents and Tasks
Creating Explicit Intents at Runtime
Using NerdLauncher as a Home Screen
For the More Curious: Processes vs Tasks
For the More Curious: Concurrent Documents
Networking Basics with Retrofit
Building the Retrofit object and creating an API instance
Moving toward the repository pattern
Deserializing JSON text into model objects
Networking Across Configuration Changes
Displaying Results in RecyclerView
For the More Curious: Alternate Parsers and Data Formats
For the More Curious: Canceling Requests
For the More Curious: Managing Dependencies
Challenge: Adding a Custom Gson Deserializer
Challenge: Dynamically Adjusting the Number of Columns
25. Loopers, Handlers, and HandlerThread
Preparing RecyclerView to Display Images
Preparing to Download Bytes from a URL
Downloading Lots of Small Things
Assembling a Background Thread
Making your thread lifecycle aware
Starting and stopping a HandlerThread
Listening to the View Lifecycle
Rotation and retained fragments
For the More Curious: Solving the Image Downloading Problem
For the More Curious: StrictMode
Challenge: Observing View LifecycleOwner LiveData
Challenge: Improving ThumbnailDownloader’s Lifecycle Awareness
Challenge: Preloading and Caching
26. SearchView and SharedPreferences
Responding to SearchView user interactions
Simple Persistence with SharedPreferences
Editing SharedPreferences with Android KTX
Challenge: Polishing Your App Some More
Providing User Control over Polling
Regular Intents vs Broadcast Intents
Filtering Foreground Notifications
Creating and registering a standalone receiver
Limiting broadcasts to your app using private permissions
Creating and registering a dynamic receiver
Passing and receiving data with ordered broadcasts
Receivers and Long-Running Tasks
For the More Curious: Local Events
For the More Curious: Limitations on Broadcast Receivers
For the More Curious: Detecting the Visibility of Your Fragment
29. Browsing the Web and WebView
The Easy Way: Implicit Intents
Using WebChromeClient to spruce things up
Dangers of handling configuration changes
For the More Curious: Injecting JavaScript Objects
For the More Curious: WebView Updates
For the More Curious: Chrome Custom Tabs (Another Easy Way)
Challenge: Using the Back Button for Browser History
30. Custom Views and Touch Events
Setting Up the DragAndDraw Project
Rendering Inside onDraw(Canvas)
For the More Curious: GestureDetector
Challenge: Accessibility Support
View transformation properties