Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Cover
Title
Copyright
Contents at a Glance
Contents
About the Author
About the Technical Reviewers
Acknowledgments
Preface
Part I: Core Concept
Chapter 1: The Big Picture
Benefits and Drawbacks of Smartphone Programming
What Androids Are Made Of
Stuff at Your Disposal
The Big Picture...of This Book
Chapter 2: How to Get Started
Step 1: Set Up Java
Install the JDK
Learn Java
Step 2: Install the Android SDK
Install the Base Tools
Install the SDKs and Add-ons
Step 3: Install the ADT for Eclipse
Step 4: Install Apache Ant
Step 5: Set Up the Emulator
Step 6: Set Up the Device
Windows
Mac OS X and Linux
Chapter 3: Your First Android Project
Step 1: Create the New Project
Eclipse
Command Line
Step 2: Build, Install, and Run the Application in Your Emulator or Device
Eclipse
Command Line
Chapter 4: Examining Your First Project
Project Structure
Root Contents
The Sweat Off Your Brow
And Now, the Rest of the Story
What You Get Out of It
Inside Your Manifest
In the Beginning, There Was the Root, and It Was Good
An Application for Your Application
Chapter 5: A Bit About Eclipse
What the ADT Gives You
Coping with Eclipse
How to Import a Non-Eclipse Project
How to Get to DDMS
How to Create an Emulator
How to Run a Project
How Not to Run Your Project
Alternative IDEs
IDEs and This Book
Chapter 6: Enhancing Your First Project
Supporting Multiple Screen Sizes
Specifying Versions
Part II: Activities
Chapter 7: Rewriting Your First Project
The Activity
Dissecting the Activity
Building and Running the Activity
Chapter 8: Using XML-Based Layouts
What Is an XML-Based Layout?
Why Use XML-Based Layouts?
OK, So What Does It Look Like?
What's with the @ Signs?
And How Do We Attach These to the Java?
The Rest of the Story
Chapter 9: Employing Basic Widgets
Assigning Labels
Button, Button, Who's Got the Button?
Fleeting Images
Fields of Green…or Other Colors
Just Another Box to Check
Throw the Switch, Igor
Turn Up the Radio
It's Quite a View
Padding
Other Useful Properties
Useful Methods
Colors
Chapter 10: Working with Containers
Thinking Linearly
LinearLayout Concepts and Properties
LinearLayout Example
The Box Model
All Things Are Relative
RelativeLayout Concepts and Properties
RelativeLayout Example
Overlap
Tabula Rasa
TableLayout Concepts and Properties
TableLayout Example
Scrollwork
Take Them to the Grid
Chapter 11: The Input Method Framework
Keyboards, Hard and Soft
Tailored to Your Needs
Tell Android Where It Can Go
Fitting In
Jane, Stop This Crazy Thing!
Chapter 12: Using Selection Widgets
Adapting to the Circumstances
Lists of Naughty and Nice
Selection Modes
Spin Control
Grid Your Lions (or Something Like That...)
Fields: Now with 35% Less Typing!
Galleries, Give or Take the Art
Chapter 13: Getting Fancy with Lists
Getting to First Base
A Dynamic Presentation
Inflating Rows Ourselves
A Sidebar About Inflation
And Now, Back to Our Story
Better. Stronger. Faster.
Using convertView
Using the Holder Pattern
Interactive Rows
Chapter 14: Still More Widgets and Containers
Pick and Choose
Time Keeps Flowing Like a River
Seeking Resolution
Putting It on My Tab
The Pieces
Wiring It Together
Adding Them Up
Flipping Them Off
Getting in Somebody’s Drawer
Other Good Stuff
Chapter 15: Embedding the WebKit Browser
A Browser, Writ Small
Loading It Up
Navigating the Waters
Entertaining the Client
Settings, Preferences, and Options (Oh, My!)
Chapter 16: Applying Menus
Flavors of Menu
Menus of Options
Menus in Context
Taking a Peek
Yet More Inflation
Menu XML Structure
Menu Options and XML
Inflating the Menu
When Giant Menus Walk the Earth
Chapter 17: Showing Pop-Up Messages
Raising Toasts
Alert! Alert!
Checking Them Out
Chapter 18: Handling Activity Lifecycle Events
Schrödinger’s Activity
Life, Death, and Your Activity
onCreate() and onDestroy()
onStart(), onRestart(), and onStop()
onPause() and onResume()
The Grace of State
Chapter 19: Handling Rotation
A Philosophy of Destruction
It's All the Same, Just Different
Picking and Viewing a Contact
Saving Your State
Now with More Savings!
DIY Rotation
Forcing the Issue
Making Sense of It All
Chapter 20: Dealing with Threads
The Main Application Thread
Making Progress with ProgressBars
Getting Through the Handlers
Messages
Runnables
Where Oh Where Has My UI Thread Gone?
Asyncing Feeling
The Theory
AsyncTask, Generics, and Varargs
The Stages of AsyncTask
A Sample Task
Threads and Rotation
Manual Activity Association
Flow of Events
Why This Works
And Now, the Caveats
Chapter 21: Creating Intent Filters
What’s Your Intent?
Pieces of Intents
Intent Routing
Stating Your Intent(ions)
Narrow Receivers
Intents for Every Occasion
The Pause Caveat
Chapter 22: Launching Activities and Subactivities
Peers and Subs
Start ’Em Up
Make an Intent
Make the Call
Tabbed Browsing, Sort Of
Chapter 23: Working with Resources
The Resource Lineup
String Theory
Plain Strings
String Formats
Styled Text
Styled Text and Formats
Got the Picture?
XML: The Resource Way
Miscellaneous Values
Dimensions
Colors
Arrays
Different Strokes for Different Folks
RTL Languages: Going Both Ways
Chapter 24: Defining and Using Styles
Styles: DIY DRY
Elements of Style
Where to Apply a Style
The Available Attributes
Inheriting a Style
The Possible Values
Themes: A Style by Any Other Name…
Part III: Honeycomb and Tablets
Chapter 25: Handling Multiple Screen Sizes
Taking the Default
Whole in One
Think About Rules, Not Positions
Consider Physical Dimensions
Avoid “Real” Pixels
Choose Scalable Drawables
Tailor-Made, Just for You (and You, and You, and…)
Adding the <supports-screens> Element
Resources and Resource Sets
Finding Your Size
Ain't Nothing Like the Real Thing
Density Differs
Adjusting the Density
Ruthlessly Exploiting the Situation
Replace Menus with Buttons
Replace Tabs with a Simple Activity
Consolidate Multiple Activities
Example: EU4You
The First Cut
Fixing the Fonts
Fixing the Icons
Using the Space
What If It Is Not a Browser?
Chapter 26: Focusing on Tablets and Larger UIs
Why the Drive to Tablets?
What the User Sees
Dealing with the Rest of the Devices
Chapter 27: Using the Action Bar
Enabling the Action Bar
Promoting Menu Items to the Action Bar
Responding to the Logo
Adding Custom Views to the Action Bar
Defining the Layout
Putting the Layout in the Menu
Getting Control of User Input
Don't Forget the Phones!
Chapter 28: Fragments
Introducing Fragments
The Problem Addressed by Fragments
The Fragments Solution
The Android Compatibility Library
Creating Fragment Classes
General Fragments
ListFragment
Other Fragment Base Classes
Fragments, Layouts, Activities, and Multiple Screen Sizes
EU4You
DetailsActivity
Fragments and Configuration Changes
Designing for Fragments
Chapter 29: Handling Platform Changes
Things That Make You Go Boom
View Hierarchy
Changing Resources
Handling API Changes
Minimum, Maximum, Target, and Build Versions
Detecting the Version
Wrapping the API
Patterns for Ice Cream Sandwich and Honeycomb
The Action Bar
Writing Tablet-Only Apps
Part IV: Data Stores, Network Services, and APIs
Chapter 30: Accessing Files
You and the Horse You Rode in On
Readin' 'n Writin'
External Storage: Giant Economy-Size Space
Where to Write
When to Write
StrictMode: Avoiding Janky Code
Setting Up StrictMode
Seeing StrictMode in Action
Development Only, Please!
Conditionally Being Strict
Linux File Systems: You Sync, You Win
Chapter 31: Using Preferences
Getting What You Want
Stating Your Preference
Introducing PreferenceFragment and PreferenceActivity
Preferences via Fragments
Preferences the New and Improved Way
Preference Headers
PreferenceFragment and StockPreferenceFragment
Avoiding Nested PreferenceScreen Elements
Intents for Headers or Preferences
Adding Backward Compatibility
The Older Model of Preference Handling
Letting Users Have Their Say
Adding a Wee Bit o' Structure
The Kind of Pop-Ups You Like
Chapter 32: Managing and Accessing Local Databases
A Quick SQLite Primer
Start at the Beginning
Setting the Table
Makin' Data
What Goes Around, Comes Around
Raw Queries
Regular Queries
Using Cursors
Custom CursorAdapters
Making Your Own Cursors
SQLite and Android Versions
Flash: Sounds Faster Than It Is
Ship Ahoy!
Data, Data, Everywhere
Chapter 33: Leveraging Java Libraries
Ants and JARs
The Outer Limits
Following the Script
Reviewing the Script
Chapter 34: Communicating via the Internet
REST and Relaxation
HTTP Operations via Apache HttpClient
Parsing Responses
Stuff to Consider
AndroidHttpClient
Leveraging Internet-Aware Android Components
Downloading Files
Continuing Our Escape from Janky Code
Part V: Services
Chapter 35: Services: The Theory
Why Services?
Setting Up a Service
Service Class
Lifecycle Methods
Manifest Entry
Communicating to Services
Sending Commands with startService()
Binding with bindService()
Communicating from Services
Callback/Listener Objects
Broadcast Intents
Pending Results
Messenger
Notifications
Chapter 36: Basic Service Patterns
The Downloader
The Design
The Service Implementation
Using the Service
The Music Player
The Design
The Service Implementation
Using the Service
The Web Service Interface
The Design
The Rotation Challenge
The Service Implementation
Using the Service
Chapter 37: Alerting Users via Notifications
Notification Configuration
Hardware Notifications
Icons
Notifications in Action
Staying in the Foreground
FakePlayer, Redux
Notifications in Ice Cream Sandwich and Honeycomb
Part VI: Other Android Capabilities
Chapter 38: Requesting and Requiring Permissions
Mother, May I?
Halt! Who Goes There?
Enforcing Permissions via the Manifest
Enforcing Permissions Elsewhere
May I See Your Documents?
New Permissions in Old Applications
Permissions: Up Front or Not at All
Chapter 39: Accessing Location-Based Services
Location Providers: They Know Where You’re Hiding
Finding Yourself
On the Move
Are We There Yet? Are We There Yet?
Testing... Testing...
Chapter 40: Mapping with MapView and MapActivity
Terms, Not of Endearment
Piling On
The Key to It All
The Bare Bones
Optional Maps
Exercising Your Control
Zoom
Center
Layers Upon Layers
Overlay Classes
Drawing the ItemizedOverlay
Handling Screen Taps
My, Myself, and MyLocationOverlay
Rugged Terrain
Maps and Fragments
Limit Yourself to the Latest Android Versions
Use onCreateView() and onActivityCreated()
Host the Fragment in a MapActivity
A Custom Alternative for Maps and Fragments
Chapter 41: Handling Telephone Calls
Report to the Manager
You Make the Call!
No, Really, You Make the Call!
Chapter 42: Fonts
Love the One You're With
Additional Fonts
Here a Glyph, There a Glyph
Chapter 43: More Development Tools
Hierarchy Viewer: How Deep Is Your Code?
DDMS: Under Android's Hood
Logging
File Push and Pull
Screenshots
Location Updates
Placing Calls and Messages
Memory Management
adb: Like DDMS, with More Typing
Getting Graphical
Part VII: Alternative Application Environments
Chapter 44: The Role of Alternative Environments
In the Beginning, There Was Java...
...And It Was OK
Bucking the Trend
Support, Structure
Caveat Developer
Chapter 45: HTML5
Offline Applications
What Does It Mean?
How Do You Use It?
Web Storage
What Does It Mean?
How Do You Use It?
Web SQL Database
Going to Production
Testing
Signing and Distribution
Updates
Issues You May Encounter
Android Device Versions
Screen Sizes and Densities
Limited Platform Integration
Performance and Battery
Look and Feel
Distribution
Browser Changes Post Ice Cream Sandwich
HTML5 and Alternative Android Browsers
HTML5: The Baseline
Chapter 46: PhoneGap
What Is PhoneGap?
What Do You Write In?
What Features Do You Get?
What Do Apps Look Like?
How Does Distribution Work?
What About Other Platforms?
Using PhoneGap
Installation
Creating and Installing Your Project
PhoneGap Build
PhoneGap and the Checklist Sample
Sticking to the Standards
Adding PhoneGap APIs
Issues You May Encounter
Security
Screen Sizes and Densities
Look and Feel
For More Information
Chapter 47: Other Alternative Environments
Rhodes
Flash, Flex, and AIR
JRuby and Ruboto
Mono for Android
App Inventor
Titanium Mobile
Other JVM Compiled Languages
Part VIII: The Ever-Evolving Android
Chapter 48: Dealing with Devices
This App Contains Explicit Instructions
Explicit Feature Requests
Implied Feature Requests
A Guaranteed Market
Other Stuff That Varies
Bugs, Bugs, Bugs
Device Testing
Chapter 49: Where Do We Go from Here?
Questions, Sometimes with Answers
Heading to the Source
Getting Your News Fix
Index
← Prev
Back
Next →
← Prev
Back
Next →