Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Learning Android
Preface
What’s Inside
Conventions Used in This Book
Using Code Examples
Safari® Books Online
How to Contact Us
Acknowledgments
1. Android Overview
Android Overview
Comprehensive
Open Source Platform
Designed for Mobile Devices
History
Google’s Motivation
Open Handset Alliance
Android Versions
Summary
2. The Stack
Stack Overview
Linux
Portability
Security
Features
Native Libraries
Dalvik
Android and Java
Application Framework
Applications
The APK
Application Signing
Application Distribution
What about viruses, malware, spyware, and other bad things?
Summary
3. Quick Start
Installing the Android SDK
Setting Up a PATH to Tools
Installing Eclipse
Eclipse Workspace
Setting Up Android Development Tools
Hello, World
Creating a New Project
Manifest File
Layout XML Code
Strings
The R File
Java Source Code
The Emulator
An Emulator Versus a Physical Phone
Summary
4. Main Building Blocks
What Are Main Building Blocks?
A Real-World Example
Activities
Activity Life Cycle
Starting state
Running state
Paused state
Stopped state
Destroyed state
Intents
Services
Content Providers
Broadcast Receivers
Application Context
Summary
5. Yamba Project Overview
The Yamba Application
Design Philosophy
Project Design
Part 1: Android User Interface
Building an Activity
Networking and Multithreading
Debugging Android Apps
Part 2: Preferences, Filesystem, Options Menu, and Intents
The Activity
Menu System and Intents
Filesystem
Part 3: Android Services
Services
Application Object
Part 4: Working with Databases
SQLite and Android’s Support for It
Refactoring the Code Again
Part 5: Lists and Adapters
Timeline Activity
More Refactoring?
Part 6: Broadcast Receivers
Boot and Network Receivers
Timeline Receiver
Permissions
Part 7: Content Providers
Status Data
Android Widgets
Part 8: System Services
Compass and Location
Intent Service, Alarms, and Notifications
Summary
6. Android User Interface
Two Ways to Create a User Interface
Declarative User Interface
Programmatic User Interface
The Best of Both Worlds
Views and Layouts
LinearLayout
TableLayout
FrameLayout
RelativeLayout
AbsoluteLayout
Starting the Yamba Project
The StatusActivity Layout
Important Widget Properties
Strings Resource
The StatusActivity Java Class
Creating Your Application-Specific Object and Initialization Code
Compiling Code and Building Your Projects: Saving Files
Adding the jtwitter.jar Library
Updating the Manifest File for Internet Permission
Logging in Android
LogCat
LogCat from the Eclipse DDMS perspective
LogCat from the command line
Threading in Android
Single Thread
Multithreaded Execution
AsyncTask
Other UI Events
Adding Color and Graphics
Adding Images
Using the WYSIWYG editor in Eclipse
Updating directly in XML code
Adding Color
Alternative Resources
Optimizing the User Interface
Hierarchy Viewer
Summary
7. Preferences, the Filesystem, the Options Menu, and Intents
Preferences
Prefs Resource
PrefsActivity
Update the Manifest File
The Options Menu
The Menu Resource
Android System Resources
Update StatusActivity to Load the Menu
Update StatusActivity to Handle Menu Events
Strings Resource
Shared Preferences
The Filesystem Explained
Exploring the Filesystem
Filesystem Partitions
System Partition
SDCard Partition
The User Data Partition
Filesystem Security
Summary
8. Services
The Yamba Application Object
The YambaApplication Class
Update the Manifest File
Simplifying StatusActivity
UpdaterService
Creating the UpdaterService Java Class
Update the Manifest File
Add Menu Items
Update the Options Menu Handling
Testing the Service
Looping in the Service
Testing the Service
Pulling Data from Twitter
Testing the Service
Summary
9. The Database
About SQLite
DbHelper
The Database Schema and Its Creation
Four Major Operations
Cursors
First Example
Update UpdaterService
Testing the Service
Verify that the database was created
Using sqlite3
Database Constraints
Refactoring Status Data
Summary
10. Lists and Adapters
TimelineActivity
Basic TimelineActivity Layout
Introducing ScrollView
Creating the TimelineActivity Class
About Adapters
Adding a ListView to TimelineActivity
ListView versus ListActivity
Creating a Row Layout
Creating an Adapter in TimelineActivity.java
TimelineAdapter
ViewBinder: A Better Alternative to TimelineAdapter
Updating the Manifest File
Initial App Setup
Base Activity
Toggle Service
Summary
11. Broadcast Receivers
About Broadcast Receivers
BootReceiver
Registering the BootReceiver with the AndroidManifest File
Testing the Boot Receiver
The TimelineReceiver
Broadcasting Intents
The Network Receiver
Adding Custom Permissions to Send and Receive Broadcasts
Declaring Permissions in the Manifest File
Updating the Services to Enforce Permissions
Updating TimelineReceiver to Enforce Permissions
Summary
12. Content Providers
Creating a Content Provider
Defining the URI
Inserting Data
Updating Data
Deleting Data
Querying Data
Getting the Data Type
Updating the Android Manifest File
Using Content Providers Through Widgets
Implementing the YambaWidget class
Creating the XML Layout
Creating the AppWidgetProviderInfo File
Updating the Manifest File
Testing the Widget
Summary
13. System Services
Compass Demo
Common Steps in Using System Services
Getting Updates from the Compass
Compass Main Activity
Custom Rose Widget
Location Service
Where Am I? Demo
The layout
The activity for our Location listener
The manifest file
Updating Yamba to Use the Location Service
Updating Our Preferences
Updating the Yamba Application
Updating the Status Activity
Intent Service
Alarms
Pending intents
Adding an Interval to Preferences
Updating BootReceiver
Sending Notifications
Summary
14. The Android Interface Definition Language
Implementing the Remote Service
Writing the AIDL
Implementing the Service
Implementing a Parcel
Registering with the Manifest File
Implementing the Remote Client
Binding to the Remote Service
Testing That It All Works
Summary
15. The Native Development Kit (NDK)
What Is and Isn’t the NDK For?
Problems Solved by the NDK
The Toolchain
Packaging Your Libs
Documentation and Standardized Headers
An NDK Example: Fibonacci
FibLib
The JNI Header File
C Implementation
The Makefile
Building the Shared Library
The Fibonacci Activity
Testing That It All Works
Summary
Index
About the Author
Colophon
← Prev
Back
Next →
← Prev
Back
Next →