Contents
Prerequisites for Android Development
Setting Up Your Eclipse Environment
Setting Up Your Android Studio Environment
Java requirements for Android Studio
Downloading and Installing Android Studio
Learning Android’s Fundamental Components
Exploring the Structure of an Android Application
Examining the Application Life Cycle
Chapter 2: Introduction to Android Application Architecture
Exploring a Simple Android Application
Defining UI through Layout Files
Specifying Comments in Layout Files
Adding Views and View Groups in Layout Files
Specifying Control Properties in Layout Files
Indicating ViewGroup Properties
Controlling Width and Height of a Control
Introducing Resources and Backgrounds
Working with Text Controls in the Layout File
Working with Autogenerated IDs for Controls
Implementing Programming Logic
Loading the Layout File into an Activity
Responding to Button Clicks: Tying It All Together
Updating the AndroidManifest.XML
Placing the Files in the Android Project
Testing the Calculator App on a Real Device
void onCreate(Bundle savedInstanceState)
void onRestoreInstanceState(Bundle savedInstanceState)
void onSaveInstanceState(Bundle saveStateBundle)
Object onRetainNonConfigurationInstance()
General Notes on Activity Callbacks
Directory Structure of Resources
Reading Resources from Java Code
Runtime Behavior of Drawable Resources
Using Arbitrary XML Files as Resources
Working with Raw Resource Files
Reading Files from the Assets Directory
Reading Resources and Assets Without an Activity Reference
Understanding Resource Directories, Language, and Locale
Starting Activities for Results
Exercising the GET_CONTENT Action
Relating Intents and Activities
Understanding Explicit and Implicit Intents
Roadmap for Learning Android and the Rest of the Book
Track 1: UI Essentials for Your Android Applications
Track 3: Preparing/Taking Your Application to the Market
Track 4: Making Your Application Robust
Track 5: Bringing Finesse to Your Apps
Track 6: Integrating with Other Devices and the Cloud
Final Track: Getting a Helping Hand from Expert Android
As We Leave You Now with the Rest of the Book
Chapter 3: Building Basic User Interfaces and Using Controls
Building a UI Completely in Code
Building a UI Completely in XML
Building a UI in XML with Code
Understanding Android’s Common Controls
Chapter 4: Adapters and List Controls
Getting to Know SimpleCursorAdapter
Using Adapters with AdapterViews
The Basic List Control: ListView
Chapter 5: Building More Advanced UI Layouts
The LinearLayout Layout Manager
The TableLayout Layout Manager
The RelativeLayout Layout Manager
The FrameLayout Layout Manager
Customizing the Layout for Various Device Configurations
Chapter 6: Working with Menus and Action Bars
Working with Menus Through XML Files
Creating XML Menu Resource Files
Populating Activity Menu from Menu XML Files
Responding to XML-Based Menu Items
Working with Menus in Java Code
Registering a View for a Context Menu
Responding to Context Menu Items
Implementing a Standard Action Bar
Implementing a Tabbed Action Bar
Implementing a List-Based Action Bar
Exploring Action Bar and Search View
Defining a Search View Widget as a Menu Item
Creating a Search Results Activity
Specifying a Searchable XML File
Defining the Search Results Activity in the Manifest File
Identifying the Search Target for the Search View Widget
Sample Fragment App Showing the Life Cycle
FragmentTransactions and the Fragment Back Stack
Fragment Transaction Transitions and Animations
Caution When Referencing Fragments
Invoking a Separate Activity When Needed
Using startActivity() and setTargetFragment()
Chapter 9: Responding to Configuration Changes
The Default Configuration Change Process
The Destroy/Create Cycle of Activities
The Destroy/Create Cycle of Fragments
Using FragmentManager to Save Fragment State
Using setRetainInstance on a Fragment
Deprecated Configuration Change Methods
Handling Configuration Changes Yourself
Chapter 10: Working with Dialogs
Understanding Dialog Fragments
DialogFragment Sample Application
Chapter 11: Working with Preferences and Saving State
Exploring the Preferences Framework
Understanding CheckBoxPreference and SwitchPreference
Accessing a Preference Value in Code
Understanding EditTextPreference
Understanding MultiSelectListPreference
Creating Child Preferences with Dependency
Dynamic Preference Summary Text
Chapter 12: Using the Compatibility Library for Older Devices
Adding the Library to Your Project
Including the v7 Support Library
Including the v8 Support Library
Including the v13 Support Library
Including the v17 Support Library
Including Just the v4 Support Library
Retrofitting an App with the Android Support Library
Chapter 13: Exploring Packages, Processes, Threads, and Handlers
Understanding Packages and Processes
A Code Pattern for Sharing Data
Understanding Library Projects
Understanding Components and Threads
Chapter 14: Building and Consuming Services
Using the HttpClient for HTTP GET Requests
Using the HttpClient for HTTP POST Requests (a Multipart Example)
Addressing Multithreading Issues
Understanding Services in Android
Defining a Service Interface in AIDL
Implementing an AIDL Interface
Calling the Service from a Client Application
Passing Complex Types to Services
Chapter 15: Advanced AsyncTask and Progress Dialogs
Essentials of a Simple AsyncTask
Implementing Your First AsyncTask
Understanding the onPreExecute() Callback and Progress Dialog
Understanding the doInBackground() Method
Triggering onProgressUpdate() through publishProgress()
Understanding the onPostExecute() Method
Upgrading to a Deterministic Progress Dialog
Issues and Solutions for Correctly Showing the Progress of an AsyncTask
Dealing with Activity Pointers and Device Rotation
Using Retained Objects and Fragment Dialogs
Using Retained Fragments and Fragment Dialogs
Using Retained Fragments and ProgressBars
Chapter 16: Broadcast Receivers and Long-Running Services
Registering a Receiver in the Manifest File
Accommodating Multiple Receivers
Working with Out-of-Process Receivers
Using Notifications from a Receiver
Monitoring Notifications Through the Notification Manager
Starting an Activity in a Broadcast Receiver
Exploring Long-Running Receivers and Services
Understanding Long-Running Broadcast Receiver Protocol
Extending IntentService for a Broadcast Receiver
Exploring Long-Running Broadcast Service Abstraction
Designing A Long-Running Receiver
Abstracting a Wake Lock with LightedGreenRoom
Implementing a Long-Running Service
Understanding a Nonsticky Service
Understanding a Sticky Service
Understanding Redeliver Intents Option
Additional Topics in Broadcast Receivers
Chapter 17: Exploring the Alarm Manager
Setting Off an Alarm Repeatedly
Understanding Exactness of Alarms
Understanding Persistence of Alarms
Chapter 18: Exploring 2D Animation
Exploring Frame-by-Frame Animation
Using Camera to Provide Depth Perception in 2D
Exploring the AnimationListener Class
Notes on Transformation Matrices
Exploring Property Animations: The New Animation API
Understanding Property Animation
Planning a Test Bed for Property Animation
Animating Views with Object Animators
Achieving Sequential Animation with AnimatorSet
Setting Animation Relationships with AnimatorSet.Builder
Understanding View Properties Animation
Understanding Layout Transitions
Chapter 19: Exploring Maps and Location-Based Services
Understanding the Mapping Package
Obtaining a Maps API Key from Google
Adding the Maps API Key to Your Application
Understanding the Location Package
Understanding Location Services
Using Proximity Alerts and Geofencing
Chapter 20: Understanding the Media Frameworks
Bonus Online Chapter on Recording and Advanced Media
Chapter 21: Home Screen Widgets
User Experience with Home Screen Widgets
Understanding Widget Configuration Activity
Understanding the Life Cycle of a Widget
Understanding Widget Definition Phase
Implementing A Sample Widget Application
Implementing Widget Configuration Activity
Implementing a Widget Provider
GestureDetector and OnGestureListeners
Chapter 23: Implementing Drag and Drop
Basics of Drag and Drop in 3.0+
Drag-and-Drop Example Application
Laying Out the Example Drag-and-Drop Application
Responding to onDrag in the Dropzone
Setting Up the Drag Source Views
Testing the Example Drag-and-Drop Application
What Can We Know About a Sensor?
Issues with Getting Sensor Data
Using Accelerometers and Magnetic Field Sensors Together
Magnetic Declination and GeomagneticField
Chapter 25: Exploring Android Persistence and Content Providers
Saving State Using Shared Preferences
Saving State Using Internal Files
Saving State Using External Files
Saving State Using O/R Mapping Libraries
Saving State Using Content Providers
Saving State Using Network Storage
Storing Data Directly Using SQLite
Summarizing Key SQLite Packages and Classes
Defining a Database Through DDLs
Doing Transactions Through Dynamic Proxies
Exploring Databases on the Emulator and Available Devices
Exploring Android’s Built-in Providers
Understanding the Structure of Content Provider URIs
Implementing Content Providers
Using UriMatcher to Figure Out the URIs
Fulfilling MIME-Type Contracts
Implementing the Insert Method
Implementing the Update Method
Implementing the Delete Method
Chapter 26: Understanding Loaders
Understanding the Architecture of Loaders
Listing Basic Loader API Classes
Step 1: Preparing the Activity to Load Data
Step 2: Initializing the Loader
Delving into the Structure of ListActivity
Working with Asynchronous Loading of Data
Step 3: Implementing onCreateLoader()
Step 4: Implementing onLoadFinished()
Step 5: Implementing onLoaderReset()
Understanding the Order of LoaderManager Callbacks
Chapter 27: Exploring the Contacts API
Examining the Contacts SQLite Database
Understanding the Contacts Data Table
Understanding Aggregated Contacts
Exploring contact_entities_view
Adding a Contact with Its Details
Controlling Aggregation of Contacts
Understanding Personal Profile
Adding Data to the Personal Profile
Using Batch Operations to Optimize ContentProvider Updates
Idea of Batching Content Provider Updates
Reusing the Contact Provider UI
Chapter 28: Exploring Security and Permissions
Understanding the Android Security Model
Signing Applications for Deployment
Performing Runtime Security Checks
Understanding Security at the Process Boundary
Declaring and Using Permissions
Understanding and Using URI Permissions
Chapter 29: Using Google Cloud Messaging with Android
What Is Google Cloud Messaging?
Understanding the Key Building Blocks of GCM
Preparing to Use GCM in Your Application
Authenticating GCM Communication
Building an Android GCM-Enabled Application
Coding the Client Component for GCM
Coding the Server Component for GCM
Moving Beyond the GCM Introduction
Chapter 30: Deploying Your Application: Google Play Store and Beyond
Preparing Your Application for Sale
Supporting Different Screen Sizes
Preparing AndroidManifest.xml for Uploading
Preparing Your Application Icon
Directing Users Back to the Play Store
Using ProGuard for Optimization, Fighting Piracy
Preparing Your .apk File for Uploading
18.220.237.24