Home Page Icon
Home Page
Table of Contents for
Cover Page
Close
Cover Page
by Shane Conder, Lauren Darcey, Joseph Annuzzi Jr.
Advanced Android™ Application Development, Fourth Edition
About This eBook
Title Page
Copyright Page
Praise for Advanced Android™ Application Development, Fourth Edition
Dedication Page
Contents at a Glance
Contents
Acknowledgments
About the Authors
Introduction
Who Should Read This Book?
How This Book Is Structured
Key Questions Answered in This Book
An Overview of Changes in This Edition
The Development Environment Used in This Book
Supplementary Materials Available
Where to Find More Information
Conventions Used in This Book
Contacting the Authors
I: Advanced Android Application Design Principles
1. Threading and Asynchronous Processing
The Importance of Processing Asynchronously
Working with the AsyncTask Class
Working with the Thread Class
Working with Loaders
Understanding StrictMode
Summary
Quiz Questions
Exercises
References and More Information
2. Working with Services
Determining When to Use Services
Understanding the Service Lifecycle
Creating a Service
Controlling a Service
Implementing a Remote Interface
Implementing a Parcelable Class
Using the IntentService Class
Summary
Quiz Questions
Exercises
References and More Information
3. Leveraging SQLite Application Databases
Storing Structured Data Using SQLite Databases
Creating a SQLite Database
Creating, Updating, and Deleting Database Records
Working with Transactions
Querying SQLite Databases
Working with Cursors
Executing Simple Queries
Executing More Complex Queries Using SQLiteQueryBuilder
Executing Raw Queries without Builders and Column Mapping
Closing and Deleting a SQLite Database
Deleting Tables and Other SQLite Objects
Closing a SQLite Database
Deleting a SQLite Database Instance Using the Application Context
Designing Persistent Databases
Keeping Track of Database Field Names
Extending the SQLiteOpenHelper Class
Binding Data to the Application User Interface
Working with Database Data Like Any Other Data
Binding Data to Controls Using Data Adapters
Summary
Quiz Questions
Exercises
References and More Information
4. Building Android Content Providers
Acting as a Content Provider
Implementing a Content Provider Interface
Defining the Data URI
Defining Data Columns
Implementing Important Content Provider Methods
Updating the Manifest File
Enhancing Applications Using Content Providers
Summary
Quiz Questions
Exercises
References and More Information
5. Broadcasting and Receiving Intents
Sending Broadcasts
Sending Basic Broadcasts
Sending Ordered Broadcasts
Receiving Broadcasts
Registering to Receive Broadcasts
Handling Incoming Broadcasts from the System
Securing Application Broadcasts
Summary
Quiz Questions
Exercises
References and More Information
6. Working with Notifications
Notifying the User
A Word on Compatibility
Notifying with the Status Bar
Using the NotificationManager Service
Creating a Simple Text Notification with an Icon
Working with the Notification Queue
Updating Notifications
Clearing Notifications
Vibrating the Phone
Blinking the Lights
Making Noise
Customizing the Notification
Expandable and Contractible Notifications
Notification Priority
Introducing the Notification Listener
Designing Useful Notifications
Summary
Quiz Questions
Exercises
References and More Information
7. Designing Powerful User Interfaces
Following Android User Interface Guidelines
Enabling Action Bars
Building Basic Action Bars
Customizing Your Action Bar
Handling Application Icon Clicks on the Action Bar
Working with Screens That Do Not Require Action Bars
Contextual Action Mode
Working with Styles
Building Simple Styles
Leveraging Style Inheritance
Working with Themes
Summary
Quiz Questions
Exercises
References and More Information
8. Handling Advanced User Input
Working with Textual Input Methods
Working with Software Keyboards
Working with Text Prediction and User Dictionaries
Using the Clipboard Framework
Handling User Events
Listening for Touch Mode Changes
Listening for Events on the Entire Screen
Listening for Long Clicks
Listening for Focus Changes
Working with Gestures
Detecting User Motions within a View
Handling Common Single-Touch Gestures
Handling Common Multitouch Gestures
Making Gestures Look Natural
Using the Drag-and-Drop Framework
Handling Screen Orientation Changes
Summary
Quiz Questions
Exercises
References and More Information
9. Designing Accessible Applications
Exploring the Accessibility Framework
Leveraging Speech Recognition Services
Leveraging Text-to-Speech Services
Testing Application Accessibility
Summary
Quiz Questions
Exercises
References and More Information
10. Development Best Practices for Tablets, TVs, and Wearables
Understanding Device Diversity
Don’t Make Assumptions about Device Characteristics
Designing Flexible User Interfaces
Attracting New Types of Users
Leveraging Alternative Resources
Using Screen Space Effectively on Big Landscape Screens
Developing Applications for Tablets
Developing Applications for TV
Working with Google TV
Google TV Variations
Developing Applications for Wearables
Summary
Quiz Questions
Exercises
References and More Information
III: Leveraging Common Android APIs
11. Using Android Networking APIs
Understanding Mobile Networking Fundamentals
Understanding StrictMode with Networking
Accessing the Internet (HTTP)
Reading Data from the Web
Using HttpURLConnection
Parsing XML from the Network
Handling Network Operations Asynchronously
Retrieving Android Network Status
Summary
Quiz Questions
Exercises
References and More Information
12. Using Android Web APIs
Browsing the Web with WebView
Designing a Layout with a WebView Control
Loading Content into a WebView Control
Adding Features to the WebView Control
Managing WebView State
Building Web Extensions
Browsing the WebKit APIs
Extending Web Application Functionality to Android
Debugging WebViews with Chrome DevTools
Working with Adobe AIR and Flash
Summary
Quiz Questions
Exercises
References and More Information
13. Using Android Multimedia APIs
Working with Multimedia
Working with the Camera
Capturing Still Images Using the Camera
Configuring Camera Mode Settings
Working with Common Camera Parameters
Zooming the Camera
Sharing Images
Assigning Images as Wallpapers
Choosing among Various Device Cameras
Working with Video
Recording Video
Playing Video
Working with Face Detection
Working with Audio
Recording Audio
Playing Audio
Sharing Audio
Searching for Multimedia
Working with Ringtones
Introducing the Media Router
Summary
Quiz Questions
Exercises
References and More Information
14. Using Android Telephony APIs
Working with Telephony Utilities
Gaining Permission to Access Phone State Information
Requesting Call State
Requesting Service Information
Monitoring Signal Strength and Data Connection Speed
Working with Phone Numbers
Using SMS
Default Messaging Application
SMS Provider
SMS Applications Other than the Default
Making and Receiving Phone Calls
Making Phone Calls
Receiving Phone Calls
Working with SIP
Summary
Quiz Questions
Exercises
References and More Information
15. Accessing Android’s Hardware Sensors
Interacting with Device Hardware
Using the Device Sensors
Working with Different Sensors
Configuring the Android Manifest File for Sensors
Acquiring a Reference to a Sensor
Reading Sensor Data
Calibrating Sensors
Determining Device Orientation
Finding True North
Sensor Event Batching
Monitoring the Battery
Summary
Quiz Questions
Exercises
References and More Information
16. Using Android’s Optional Hardware APIs
Working with Bluetooth
Checking for the Existence of Bluetooth Hardware
Enabling Bluetooth
Querying for Paired Devices
Discovering Devices
Establishing Connections between Devices
Working with USB
Working with USB Accessories
Working as a USB Host
Working with Android Beam
Enabling Android Beam Sending
Receiving Android Beam Messages
Configuring the Manifest File for Android Beam
Android Beam over Bluetooth
Introducing Host Card Emulation
Working with Wi-Fi
Introducing Wi-Fi Direct
Monitoring Wi-Fi State
Summary
Quiz Questions
Exercises
References and More Information
IV: Leveraging Google APIs
17. Using Location and Map APIs
Incorporating Android Location APIs
Using the Global Positioning System (GPS)
Geocoding Locations
Doing More with Android Location-Based Services
Incorporating Google Location Services APIs
Locating with the Fused Location Provider
Doing More with Google Location Services
Incorporating Google Maps Android API v2
Mapping Locations
Summary
Quiz Questions
Exercises
References and More Information
18. Working with Google Cloud Messaging
An Overview of GCM
Understanding GCM Message Flow
Understanding the Limitations of the GCM Service
Signing Up for GCM
Incorporating GCM into Your Applications
Exploring the GCM Sample Applications
What Alternatives to GCM Exist?
Summary
Quiz Questions
Exercises
References and More Information
19. An Overview of In-App Billing APIs for Android
What Is In-App Billing?
Using In-App Billing
Leveraging Google Play In-App Billing APIs
Leveraging Amazon Appstore for Android In-App Purchasing APIs
Leveraging PayPal Billing APIs
Leveraging Other Billing APIs
Summary
Quiz Questions
Exercises
References and More Information
20. Enabling Application Statistics with Google Analytics
Creating a Google Account for Analytics
Adding the Library to Your Android IDE Project
Collecting Data from Your Applications
Logging Different Events
Using the Google Analytics Dashboard
Gathering E-commerce Information
Logging E-commerce Events in Your Applications
Reviewing E-commerce Reports
Tracking Ad and Market Referrals
Gathering Statistics
Protecting Users’ Privacy
Summary
Quiz Questions
Exercises
References and More Information
21. An Overview of Google Play Game Services
Getting Up and Running with Google Play Game Services
Incorporating Google Play Game Services into Your Applications
Understanding Achievements
Understanding Leaderboards
Saving Game Data with Cloud Save
Introducing Multiplayer Gaming
Understanding Antipiracy
Summary
Quiz Questions
Exercises
References and More Information
V: Drawing, Animations, and Graphics Programming with Android
22. Developing Android 2D Graphics Applications
Drawing on the Screen
Working with Canvases and Paints
Understanding the Canvas Object
Understanding the Paint Object
Working with Text
Using Default Fonts and Typefaces
Using Custom Typefaces
Measuring Text Screen Requirements
Working with Bitmaps
Drawing Bitmap Graphics on a Canvas
Scaling Bitmap Graphics
Transforming Bitmaps Using Matrixes
Bitmap Performance Optimizations
Working with Shapes
Defining Shape Drawables as XML Resources
Defining Shape Drawables Programmatically
Drawing Different Shapes
Leveraging Hardware Acceleration Features
Controlling Hardware Acceleration
Fine-Tuning Hardware Acceleration
Summary
Quiz Questions
Exercises
References and More Information
23. Working with Animation
Animating Your Applications
Working with Drawable Animation
Working with View Animations
Working with Property Animation
Working with Different Interpolators
Animating Activity Launch
State Animations with Scenes and Transitions
Summary
Quiz Questions
Exercises
References and More Information
24. Developing Android 3D Graphics Applications
Working with OpenGL ES
Leveraging OpenGL ES in Android
Ensuring Device Compatibility
Using OpenGL ES APIs in the Android SDK
Handling OpenGL ES Tasks Manually
Creating a SurfaceView
Starting Your OpenGL ES Thread
Initializing EGL
Initializing GL
Drawing on the Screen
Drawing 3D Objects
Drawing Your Vertices
Coloring Your Vertices
Drawing More Complex Objects
Lighting Your Scene
Texturing Your Objects
Interacting with Android Views and Events
Enabling the OpenGL Thread to Talk to the Application Thread
Enabling the Application Thread to Talk to the OpenGL Thread
Cleaning Up OpenGL ES
Using GLSurfaceView (Easy OpenGL ES)
Using OpenGL ES 2.0
Configuring Your Application for OpenGL ES 2.0
Requesting an OpenGL ES 2.0 Surface
Exploring OpenGL ES 3.0
Summary
Quiz Questions
Exercises
References and More Information
25. Using the Android NDK
Determining When to Use the Android NDK
Installing the Android NDK
Exploring the Android NDK Sample Application
Creating Your Own NDK Project
Calling Native Code from Java
Handling Parameters and Return Values
Using Exceptions with Native Code
Using Native Activities
Improving Graphics Performance
Comparing RenderScript to the NDK
Computing with RenderScript
Native RenderScript
Summary
Quiz Questions
Exercises
References and More Information
VI: Maximizing Android’s Unique Features
26. Extending Android Application Reach
Enhancing Your Applications
Working with App Widgets
Creating an App Widget
Installing an App Widget to the Home Screen
Becoming an App Widget Host
Introducing Lock Screen App Widgets
Installing an App Widget to the Lock Screen
Working with Live Wallpapers
Creating a Live Wallpaper
Creating a Live Wallpaper Service
Creating a Live Wallpaper Configuration
Configuring the Android Manifest File for Live Wallpapers
Installing a Live Wallpaper
Introducing Daydream
Acting as a Content Type Handler
Determining Intent Actions and MIME Types
Implementing the Activity to Process the Intents
Registering the Intent Filter
Summary
Quiz Questions
Exercises
References and More Information
27. Enabling Application Search
Making Application Content Searchable
Enabling Searches in Your Application
Creating a Search Configuration
Creating a Search Activity
Configuring the Android Manifest File for Search
Enabling Global Search
Updating a Search Configuration for Global Searches
Updating Search Settings for Global Searches
Summary
Quiz Questions
Exercises
References and More Information
28. Managing User Accounts and Synchronizing User Data
Managing Accounts with the Account Manager
Multiple Users, Restricted Profiles, and Accounts
Synchronizing Data with Sync Adapters
Using Backup Services
Choosing a Remote Backup Service
Implementing a Backup Agent
Backing Up and Restoring Application Data
Summary
Quiz Questions
Exercises
References and More Information
VII: Advanced Topics in Application Publication and Distribution
29. Internationalizing Your Applications
Localizing Your Application’s Language
Internationalization Using Alternative Resources
Changing the Language Settings
Implementing Locale Support Programmatically
Right-to-Left Language Localization
Translation Services through Google Play
Using the Developer Console
Publishing Applications for Foreign Users
Summary
Quiz Questions
Exercises
References and More Information
30. Protecting Applications from Software Piracy
All Applications Are Vulnerable
Using Secure Coding Practices
Obfuscating with ProGuard
Configuring ProGuard for Your Android Applications
Dealing with Error Reports after Obfuscation
Leveraging the License Verification Library
Other Antipiracy Tips
Summary
Quiz Questions
Exercises
References and More Information
VIII: Preparing for Future Android Releases
31. Introducing the L Developer Preview
Exploring the L Developer Preview
Improving Performance
Improving the User Experience
Introducing Android TV
Understanding Android TV Development Requirements
Understanding TV Application Hardware Limitations
Summary
Quiz Questions
Exercises
References and More Information
IX: Appendixes
A. Quick-Start Guide: Android Debug Bridge
Listing Connected Devices and Emulators
Directing ADB Commands to Specific Devices
Starting and Stopping the ADB Server
Stopping the ADB Server Process
Starting and Checking the ADB Server Process
Listing ADB Commands
Issuing Shell Commands
Issuing a Single Shell Command
Using a Shell Session
Using the Shell to Start and Stop the Emulator
Copying Files
Sending Files to a Device or Emulator
Retrieving Files from a Device or Emulator
Installing and Uninstalling Applications
Installing Applications
Reinstalling Applications
Uninstalling Applications
Working with LogCat Logging
Displaying All Log Information
Including Date and Time with Log Data
Filtering Log Information
Clearing the Log
Redirecting Log Output to a File
Accessing the Secondary Logs
Controlling the Backup Service
Forcing Backup Operations
Forcing Restore Operations
Wiping Archived Data
Generating Bug Reports
Using the Shell to Inspect SQLite Databases
Using the Shell to Stress Test Applications
Letting the Monkey Loose on Your Application
Listening to Your Monkey
Directing Your Monkey’s Actions
Training Your Monkey to Repeat His Tricks
Keeping the Monkey on a Leash
Learning More about Your Monkey
Installing Custom Binaries via the Shell
Summary
Quiz Questions
Exercises
References and More Information
B. Quick-Start Guide: SQLite
Exploring Common Tasks with SQLite
Using the sqlite3 Command-Line Interface
Launching the ADB Shell
Connecting to a SQLite Database
Exploring Your Database
Importing and Exporting the Database and Its Data
Executing SQL Commands on the Command Line
Using Other sqlite3 Commands
Understanding SQLite Limitations
Learning by Example: A Student Grade Database
Designing the Student Grade Database Schema
Creating Simple Tables with AUTOINCREMENT
Inserting Data into Tables
Querying Tables for Results with SELECT
Using Foreign Keys and Composite Primary Keys
Altering and Updating Data in Tables
Querying Multiple Tables Using JOIN
Using Calculated Columns
Using Subqueries for Calculated Columns
Deleting Tables
Summary
Quiz Questions
Exercises
References and More Information
C. Java for Android Developers
Learning the Java Programming Language
Learning the Java Development Tools
Familiarizing Yourself with Java Documentation
Understanding Java Shorthand
Chaining Methods and Unnecessary Temp Variables
Looping Infinitely
Working with Unary and Ternary Operators
Working with Inner Classes
Summary
Quiz Questions
Exercises
References and More Information
D. Quick-Start Guide: Android Studio
Getting Up and Running with Android Studio
Launching Android Studio for the First Time
Configuring Android Studio
Creating an Android Studio Project
Understanding the Android Studio Project Structure
Learning about the Gradle Build System
Overview of the Android Studio User Interface
Introducing the Layout Editor
Working in Design View
Working in Text View
Using the Preview Controls
Debugging Your Android Studio Applications
Setting Breakpoints
Stepping through Code
Useful Keyboard Shortcuts
Summary
Quiz Questions
Exercises
References and More Information
E. Answers to Quiz Questions
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16
Chapter 17
Chapter 18
Chapter 19
Chapter 20
Chapter 21
Chapter 22
Chapter 23
Chapter 24
Chapter 25
Chapter 26
Chapter 27
Chapter 28
Chapter 29
Chapter 30
Chapter 31
Appendix A
Appendix B
Appendix C
Appendix D
Index
Code Snippets
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
About This eBook
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset