Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Preface

Preface to the First Edition

Acknowledgments

About this Book

About the Cover Illustration

1. What is Android?—The Big Picture

Chapter 1. Introducing Android

1.1. The Android platform

1.2. Understanding the Android market

1.2.1. Mobile operators

1.2.2. Android vs. the feature phones

1.2.3. Android vs. the smartphones

1.2.4. Android vs. itself

1.2.5. Licensing Android

1.3. The layers of Android

1.3.1. Building on the Linux kernel

1.3.2. Running in the Dalvik VM

1.4. The Intent of Android development

1.4.1. Empowering intuitive UIs

1.4.2. Intents and how they work

1.5. Four kinds of Android components

1.5.1. Activity

1.5.2. Service

1.5.3. BroadcastReceiver

1.5.4. ContentProvider

1.6. Understanding the AndroidManifest.xml file

1.7. Mapping applications to processes

1.8. Creating an Android application

1.9. Summary

Chapter 2. Android’s development environment

2.1. Introducing the Android SDK

2.1.1. Core Android packages

2.1.2. Optional packages

2.2. Exploring the development environment

2.2.1. The Java perspective

2.2.2. The DDMS perspective

2.2.3. Command-line tools

2.3. Building an Android application in Eclipse

2.3.1. The Android Project Wizard

2.3.2. Android sample application code

2.3.3. Packaging the application

2.4. Using the Android emulator

2.4.1. Setting up the emulated environment

2.4.2. Testing your application in the emulator

2.5. Debugging your application

2.6. Summary

2. Exercising the Android SDK

Chapter 3. User interfaces

3.1. Creating the Activity

3.1.1. Creating an Activity class

3.1.2. Exploring the Activity lifecycle

3.2. Working with views

3.2.1. Exploring common views

3.2.2. Using a ListView

3.2.3. Multitasking with Handler and Message

3.2.4. Creating custom views

3.2.5. Understanding layout

3.2.6. Handling focus

3.2.7. Grasping events

3.3. Using resources

3.3.1. Supported resource types

3.3.2. Referencing resources in Java

3.3.3. Defining views and layouts through XML resources

3.3.4. Externalizing values

3.3.5. Providing animations

3.4. Exploring the AndroidManifest file

3.5. Summary

Chapter 4. Intents and Services

4.1. Serving up RestaurantFinder with Intent

4.1.1. Defining Intents

4.1.2. Implicit and explicit invocation

4.1.3. Adding external links to RestaurantFinder

4.1.4. Finding your way with Intent

4.1.5. Taking advantage of Android-provided activities

4.2. Checking the weather with a custom URI

4.2.1. Offering a custom URI

4.2.2. Inspecting a custom Uri

4.3. Checking the weather with broadcast receivers

4.3.1. Broadcasting Intent

4.3.2. Creating a receiver

4.4. Building a background weather service

4.5. Communicating with the WeatherAlertService from other apps

4.5.1. Android Interface Definition Language

4.5.2. Binder and Parcelable

4.5.3. Exposing a remote interface

4.5.4. Binding to a Service

4.5.5. Starting versus binding

4.5.6. Service lifecycle

4.6. Summary

Chapter 5. Storing and retrieving data

5.1. Using preferences

5.1.1. Working with SharedPreferences

5.1.2. Preference access permissions

5.2. Using the filesystem

5.2.1. Creating files

5.2.2. Accessing files

5.2.3. Files as raw resources

5.2.4. XML file resources

5.2.5. External storage via an SD card

5.3. Persisting data to a database

5.3.1. Building and accessing a database

5.3.2. Using the sqlite3 tool

5.4. Working with ContentProvider classes

5.4.1. Using an existing ContentProvider

5.4.2. Creating a ContentProvider

5.5. Summary

Chapter 6. Networking and web services

6.1. An overview of networking

6.1.1. Networking basics

6.1.2. Clients and servers

6.2. Checking the network status

6.3. Communicating with a server socket

6.4. Working with HTTP

6.4.1. Simple HTTP and java.net

6.4.2. Robust HTTP with HttpClient

6.4.3. Creating an HTTP and HTTPS helper

6.5. Web services

6.5.1. POX—Putting it together with HTTP and XML

6.5.2. REST

6.5.3. To SOAP or not to SOAP, that is the question

6.6. Summary

Chapter 7. Telephony

7.1. Exploring telephony background and terms

7.1.1. Understanding GSM

7.1.2. Understanding CDMA

7.2. Accessing telephony information

7.2.1. Retrieving telephony properties

7.2.2. Obtaining phone state information

7.3. Interacting with the phone

7.3.1. Using intents to make calls

7.3.2. Using phone number-related utilities

7.3.3. Intercepting outbound calls

7.4. Working with messaging: SMS

7.4.1. Sending SMS messages

7.4.2. Receiving SMS messages

7.5. Summary

Chapter 8. Notifications and alarms

8.1. Introducing Toast

8.1.1. Creating an SMS example with a Toast

8.1.2. Receiving an SMS message

8.2. Introducing notifications

8.2.1. The Notification class

8.2.2. Notifying a user of an SMS

8.3. Introducing Alarms

8.3.1. Creating a simple alarm example

8.3.2. Using notifications with Alarms

8.4. Summary

Chapter 9. Graphics and animation

9.1. Drawing graphics in Android

9.1.1. Drawing with XML

9.1.2. Exploring XML drawable shapes

9.2. Creating animations with Android’s Graphics API

9.2.1. Android’s frame-by-frame animation

9.2.2. Programmatically creating an animation

9.3. Introducing OpenGL for Embedded Systems

9.3.1. Creating an OpenGL context

9.3.2. Drawing a rectangle with OpenGL ES

9.3.3. Three-dimensional shapes and surfaces with OpenGL ES

9.4. Summary

Chapter 10. Multimedia

10.1. Introduction to multimedia and OpenCORE

10.2. Playing audio

10.3. Playing video

10.4. Capturing media

10.4.1. Understanding the camera

10.4.2. Capturing audio

10.5. Recording video

10.6. Summary

Chapter 11. Location, location, location

11.1. Simulating your location within the emulator

11.1.1. Sending in your coordinates with the DDMS tool

11.1.2. The GPS Exchange Format

11.1.3. The Google Earth Keyhole Markup Language

11.2. Using LocationManager and LocationProvider

11.2.1. Accessing location data with LocationManager

11.2.2. Using a LocationProvider

11.2.3. Receiving location updates with LocationListener

11.3. Working with maps

11.3.1. Extending MapActivity

11.3.2. Using a MapView

11.3.3. Placing data on a map with an Overlay

11.4. Converting places and addresses with Geocoder

11.5. Summary

3. Android applications

Chapter 12. Putting Android to work in a field service application

12.1. Designing a real-world Android application

12.1.1. Core requirements of the application

12.1.2. Managing the data

12.1.3. Application architecture and integration

12.2. Mapping out the application flow

12.2.1. Mapping out the field service application

12.2.2. List of source files

12.2.3. Field service application’s AndroidManifest.xml

12.3. Application source code

12.3.1. Splash Activity

12.3.2. Preferences used by the FieldService Activity

12.3.3. Implementing the FieldService Activity

12.3.4. Settings

12.3.5. Managing job data

12.4. Source code for managing jobs

12.4.1. RefreshJobs

12.4.2. Managing jobs: The ManageJobs Activity

12.4.3. Working with a job with the ShowJob Activity

12.4.4. Capturing a signature with the CloseJob Activity

12.5. Server code

12.5.1. Dispatcher user interface

12.5.2. Database

12.5.3. PHP dispatcher code

12.5.4. PHP mobile integration code

12.6. Summary

Chapter 13. Building Android applications in C

13.1. Building Android apps without the SDK

13.1.1. The C compiler and linker tools

13.1.2. Building a Hello World application

13.1.3. Installing and running the application

13.1.4. C application build script

13.2. Solving the problem with dynamic linking

13.2.1. Android system libraries

13.2.2. Building a dynamically linked application

13.2.3. exit() versus return()

13.2.4. Startup code

13.3. What time is it? The DayTime Server

13.3.1. DayTime Server application

13.3.2. daytime.c

13.3.3. The SQLite database

13.3.4. Building and running the DayTime Server

13.4. Daytime Client

13.4.1. Activity

13.4.2. Socket Client

13.4.3. Testing the Daytime Client

13.5. Summary

4. The maturing platform

Chapter 14. Bluetooth and sensors

14.1. Exploring Android’s Bluetooth capabilities

14.1.1. Replacing cables

14.1.2. Primary and secondary roles and sockets

14.1.3. Trusting a device

14.1.4. Connecting to a remote device

14.1.5. Capturing Bluetooth events

14.1.6. Bluetooth permissions

14.2. Interacting with the SensorManager

14.2.1. Types of sensors

14.2.2. Reading sensor values

14.2.3. Enabling and disabling sensors

14.3. Building the SenseBot application

14.3.1. User interface

14.3.2. Interpreting sensor values

14.3.3. Driving the robot

14.3.4. Communication with the robot

14.4. Summary

Chapter 15. Integration

15.1. Understanding the Android contact model

15.1.1. Choosing open-ended records

15.1.2. Dealing with multiple accounts

15.1.3. Unifying a local view from diverse remote stores

15.1.4. Sharing the playground

15.2. Getting started with LinkedIn

15.3. Managing contacts

15.3.1. Leveraging the built-in contacts app

15.3.2. Requesting operations from your app

15.3.3. Directly reading and modifying the contacts database

15.3.4. Adding contacts

15.4. Keeping it together

15.4.1. The dream of sync

15.4.2. Defining accounts

15.4.3. Telling secrets: The AccountManager service

15.5. Creating a LinkedIn account

15.5.1. Not friendly to mobile

15.5.2. Authenticating to LinkedIn

15.6. Synchronizing to the backend with SyncAdapter

15.6.1. The synchronizing lifecycle

15.6.2. Synchronizing LinkedIn data

15.7. Wrapping up: LinkedIn in action

15.7.1. Finalizing the LinkedIn project

15.7.2. Troubleshooting tips

15.7.3. Moving on

15.8. Summary

Chapter 16. Android web development

16.1. What’s Android web development?

16.1.1. Introducing WebKit

16.1.2. Examining the architectural options

16.2. Optimizing web applications for Android

16.2.1. Designing with mobile in mind

16.2.2. Adding the viewport tag

16.2.3. Selectively loading content

16.2.4. Interrogating the user agent

16.2.5. The media query

16.2.6. Considering a made-for-mobile application

16.3. Storing data directly in the browser

16.3.1. Setting things up

16.3.2. Examining the code

16.3.3. The user interface

16.3.4. Opening the database

16.3.5. Unpacking the transaction function

16.3.6. Inserting and deleting rows

16.3.7. Testing the application with WebKit tools

16.4. Building a hybrid application

16.4.1. Examining the browser control

16.4.2. Wiring up the control

16.4.3. Implementing the JavaScript handler

16.4.4. Accessing the code from JavaScript

16.4.5. Digging into the JavaScript

16.4.6. Security matters

16.4.7. Implementing a WebViewClient

16.4.8. Augmenting the browser

16.4.9. Detecting navigation events

16.4.10. Implementing the WebChromeClient

16.5. Summary

Chapter 17. AppWidgets

17.1. Introducing the AppWidget

17.1.1. What’s an AppWidget?

17.1.2. AppWidget deployment strategies

17.2. Introducing SiteMonitor

17.2.1. Benefits of SiteMonitor

17.2.2. The user experience

17.3. SiteMonitor application architecture

17.3.1. Bird’s-eye view of the application

17.3.2. File by file

17.4. AppWidget data handling

17.5. Implementing the AppWidgetProvider

17.5.1. AppWidgetProvider method inventory

17.5.2. Implementing SiteMonitorWidgetImpl

17.5.3. Handling zombie widgets

17.6. Displaying an AppWidget with RemoteViews

17.6.1. Working with RemoteViews

17.6.2. UpdateOneWidget explained

17.7. Configuring an instance of the AppWidget

17.7.1. AppWidget metadata

17.7.2. Working with Intent data

17.7.3. Confirming widget creation

17.8. Updating the AppWidget

17.8.1. Comparing services to alarms

17.8.2. Triggering the update

17.8.3. Updating the widgets, finally!

17.9. Tying it all together with AndroidManifest.xml

17.10. Summary

Chapter 18. Localization

18.1. The need for localization

18.2. Exploring locales

18.3. Strategies for localizing an application

18.3.1. Identifying target locales and data

18.3.2. Identifying and managing strings

18.3.3. Drawables and layouts

18.3.4. Dates, times, numbers, and currencies

18.3.5. Working with the translation team

18.4. Leveraging Android resource capabilities

18.4.1. More than locale

18.4.2. Assigning strings in resources

18.5. Localizing in Java code

18.6. Formatting localized strings

18.7. Obstacles to localization

18.8. Summary

Chapter 19. Android Native Development Kit

19.1. Introducing the NDK

19.1.1. Uses for the NDK

19.1.2. Looking at the NDK

19.2. Building an application with the NDK

19.2.1. Demonstrating the completed application

19.2.2. Examining the project structure

19.3. Building the JNI library

19.3.1. Understanding JNI

19.3.2. Implementing the library

19.3.3. Compiling the JNI library

19.4. Building the user interface

19.4.1. User interface layout

19.4.2. Taking a photo

19.4.3. Finding the edges

19.5. Integrating the NDK into Eclipse

19.6. Summary

Appendix A. Installing the Android SDK

A.1. Development environment requirements

A.2. Obtaining and installing Eclipse

A.3. Obtaining and installing the Android SDK

A.4. Using the SDK and AVD Manager

A.5. Obtaining and installing the Eclipse plug-in

A.6. Configuring the Eclipse plug-in

Appendix B. Publishing applications

B.1. Preparing an application for distribution

B.1.1. Logging

B.1.2. Debugging notifications

B.1.3. Sample data

B.1.4. AndroidManifest.xml

B.1.5. End-user license agreement

B.1.6. Testing

B.1.7. Finishing touches

B.2. Digitally signing an application

B.2.1. Keystores

B.2.2. keytool

B.2.3. jarsigner

B.3. Publishing to the Android Market

B.3.1. The Market rules

B.3.2. Getting your application in the Market

B.3.3. Android Market—the right solution

B.4. Other distribution means

B.5. Recapping the Android Debug Bridge

Index

List of Figures

List of Tables

List of Listings

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset