9781449390501
index.html

Learning Android

Marko Gargenta

All Rights Reserved

Abstract

If you're new to the Android mobile operating system, Learning Android is the perfect way to master the fundamentals. This gentle introduction shows you how to use Android's basic building blocks to develop user interfaces, store data, and more. Buy the print book or ebook.

Note

You are reading the text of an O'Reilly book that's under development. The author is publishing the book to this site as it's being written, and we're putting it here to get feedback from you. This book uses the Open Feedback Publishing System (OFPS), an O'Reilly experiment that tries to bridge the gap between private manuscripts and public blogs.

Next to every paragraph, there is a link you can use to comment on what you're reading. We are grateful for any feedback you have: questions, comments, suggestions, and corrections are all welcome and appreciated.

Learn more and preorder at the book's catalog page.


Preface
What’s Inside
Conventions Used in This Book
Using Code Examples
Safari® Books Online
Acknowledgements
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
App Framework
Applications
The APK
Application Signing
App Distribution
Summary
3. Quick Start
Installing the Android SDK
Setting up PATH to Tools
Installing Eclipse
Eclipse Workspace
Setting Up Android Development Tools
Hello, World
Creating 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
Main Building Blocks
A Real World Example
Activities
Activity Lifecycle
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, File System, Options Menu, and Intents
The Activity
Menu System and Intents
File System
Part 3: Android Services
Android Services
Application object
Part 4: Working with Databases
SQLite and Android support for it
Refactoring the code, again
Part 5: Lists and Adapters
Timeline Activity
Lists and Adapters
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 & Location
Intent Service, Alarms, Notifications
Summary
6. Android User Interface
Two Ways to Create User Interface
Declarative User Interface
Programmatic User Interface
The Best of Both Worlds
Views and Layouts
LinearLayout
TableLayout
FrameLayout
RelativeLayout
AbsoluteLayout
Starting Yamba Project
StatusActivity Layout
Important Widget Properties
Strings Resource
StatusActivity Java Class
Creating your application-specific object and initialization code
Compiling Code and Building Your Projects: Saving Files
Adding jtwitter.jar Library
Updating Manifest File for Internet Permission
Logging in Android
LogCat
LogCat from Eclipse DDMS Perspective
LogCat from command line
Threading in Android
Single Thread
Multithreaded Execution
AsyncTask
Other UI Events
Adding Color & Graphics
Adding Images
Adding Color
Alternative Resources
Optimizing User Interface
Hierarchy Viewer
Summary
7. Preferences, File System, Options Menu, and Intents
Preferences
Prefs Resource
PrefsActivity
Update Manifest File
Options Menu
Menu Resource
Android System Resources
Update StatusActivity to Load Menu
Update StatusActivity to Handle Menu Events
Strings Resource
Shared Preferences
File System, Explained
Exploring File System
File System Partitions
System Partition
SDCard Partition
User Data Partition
File System Security
Summary
8. Services
Yamba Application Object
YambaApplication Class
Updating Manifest File
Simplifying Status Activity
UpdaterService
Creating UpdaterService Java Class
Update the Manifest File
Add Menu Items
Update Options Menu Handling
Testing it all works
Looping In The Service
Testing it all works
Pulling Data From Twitter
Testing it all works
Summary
9. Database
About SQLite
DbHelper
The database schema and its creation
Four major operations
Cursors
First example
Update UpdaterService
Testing It Works
Database Constraints
Refactoring Status Data
Summary
10. Lists and Adapters
TimelineActivity
Basic TimelineActivity Layout
Introducing ScrollView
Creating TimelineActivity Class
About Adapters
Adding ListView to TimelineActivity
Creating a Row Layout
Creating an Adapter in TimelineActivity.java
TimelineAdapter
ViewBinder: A Better Alternative to TimelineAdapter
Updating 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
Update Timeline Receiver to Enforce Permissions
Summary
12. Content Providers
Creating 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
Test That It Works
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
Updating Yamba to Use the Location Service
Updating Our Preferences
Updating the Yamba Application
Updating the Status Activity
Intent Service
Alarms
Adding Interval to Preferences
Updating Boot Receiver
Sending Notifications
Summary
14. 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 All Works
Summary
15. Native Development Kit (NDK)
What Is and Isn’t NDK For?
Problems Solved by the NDK
Tool Chain
Packaging Your Libs
Documentation and Standardized Headers
NDK Example - Fibonacci
FibLib
JNI Header File
C Implementation
The Makefile
Building Shared Library
Fibonacci Activity
Testing It All Works
Summary
Site last updated on: April 8, 2011 at 12:51:47 PM PDT
Cover for Learning Android

View 2 comments

  1. Clemens Hladek – Posted Jan. 31, 2011

    I would really appreciate - no, love it - if I as a commentor was allowed to EDIT my own comments (typos - or even DELETING them if worked into your text).

    Next it would feel great if you / OReilly somehow would set a "flag" indicating that - or IF - a comment is/will be used to improve this book. Some older ones were evidently NOT used ...

  2. John Leasia – Posted May 12, 2011

    There's a heck of a lot of missing 'the's and 'a's and mismatches of singular/plurals - too many to add comments every time I see one. Hope someone edits it for those.

    Ofter, the add a comment link wasn't showing up near paragraphs where I had a comment, so some comments not exactly near the relevant text.

Add a comment

View 1 comment

  1. Clemens Hladek – Posted Jan. 31, 2011

    I assume that the final text will be run through a text correcting process!?!

    Meaning that I will not remark - e.g. - on missing words like "a"or "the" as in "THE user will..."

    Maybe add just one sentence above in respect to this issue?

Add a comment