List of Figures

Chapter 1. Introducing Android

Figure 1.1. Android is software only. By leveraging its Linux kernel to interface with the hardware, Android runs on many different devices from multiple cell phone manufacturers. Developers write applications in Java.

Figure 1.2. Android’s built-in browser technology is based on WebKit’s browser engine.

Figure 1.3. The Android stack offers an impressive array of technologies and capabilities.

Figure 1.4. Intents are distributed to Android applications, which register themselves by way of the IntentFilter, typically in the AndroidManifest.xml file.

Figure 1.5. The content provider is the data tier for Android applications and is the prescribed manner in which data is accessed and shared on the device.

Figure 1.6. Applications are listed in the launcher based on their IntentFilter. In this example, the application Where Do You Live is available in the LAUNCHER category.

Figure 1.7. This Android application demonstrates a simple Activity and Intent.

Chapter 2. Android’s development environment

Figure 2.1. The development environment for building Android applications, including the popular open source Eclipse IDE

Figure 2.2. The Package Explorer allows you to browse the elements of your Android projects.

Figure 2.3. The Problems view shows any errors in your source code.

Figure 2.4. The Javadoc view provides context-sensitive documentation, in this case for the Activity class.

Figure 2.5. DDMS perspective with an application running in the Android emulator

Figure 2.6. Delete applications from the emulator by highlighting the application file and clicking the Delete button.

Figure 2.7. Sending a test SMS to the Android emulator

Figure 2.8. The adb tool provides interaction at runtime with the Android emulator.

Figure 2.9. Using the shell command of the adb, you can browse Android’s filesystem.

Figure 2.10. Using the Android Project Wizard, it’s easy to create an empty Android application, ready for customization.

Figure 2.11. Using the GUI Layout tool provided in the ADT to define the user interface elements of your application

Figure 2.12. The ADT employs tools from the Android SDK to convert source files to a package that’s ready to run on an Android device or emulator.

Figure 2.13. The Android application file format is pzip compatible.

Figure 2.14. The installed Android packages listed in the AVD and SDK Manager

Figure 2.15. Creating a new AVD includes defining characteristics such as SD card storage capacity and screen resolution.

Figure 2.16. Available AVDs defined. You can set up as many different AVD instances as your requirements demand.

Figure 2.17. Creating a new launch configuration for testing your Android application

Figure 2.18. Create a new run configuration based on the Android template.

Figure 2.19. Setting up the Android emulator launch configuration

Figure 2.20. Selecting the AVD to host the application and specify launch parameters.

Figure 2.21. Adding the run configuration to the toolbar menu

Figure 2.22. Starting this chapter’s sample application, an Android tip calculator.

Figure 2.23. The Debug perspective permits you to step line-by-line through an Android application.

Chapter 3. User interfaces

Figure 3.1. High-level diagram of activity, view, resources, and manifest relationship, showing that activities are made up of views, and views use resources.

Figure 3.2. RestaurantFinder application screenshots, showing three Activitys: ReviewCriteria, ReviewList, and ReviewDetail

Figure 3.3. Android Activity lifecycle diagram, showing the methods involved in the foreground and visible phases

Figure 3.4. A class diagram of the Android View API, showing the root View class and specializations from there; note that ViewGroup classes, such as layouts, are also a type of View.

Figure 3.5. Using the Handler class with separate threads, and the relationship between HandlerThread, Looper, and MessageQueue

Figure 3.6. Common ViewGroup classes with LayoutParams and properties provided

Figure 3.7. A class diagram depicting the Observer design pattern. Each Observable component has zero to many Observers, which can be notified of changes when necessary.

Chapter 4. Intents and Services

Figure 4.1. Menu buttons on the RestaurantFinder sample application that invoke external applications

Figure 4.2. The portions of a URI that are used in Android, showing scheme, authority, and path

Figure 4.3. Example Intent and IntentFilter matching using a filter defined in XML

Figure 4.4. The WeatherReporter application, showing the weather forecast for the current location

Figure 4.5. Warning from a background application about severe weather

Figure 4.6. Diagram of the Android AIDL process

Chapter 5. Storing and retrieving data

Figure 5.1. The Android File Explorer view showing preferences file permissions

Figure 5.2. Two separate applications getting and setting SharedPreferences

Figure 5.3. The example ReadXMLResourceFile Activity that we’ll create in listing 5.8, which reads a res/xml resource file

Figure 5.4. The WeatherReporter Saved Locations screen, which pulls data from a SQLite database

Chapter 6. Networking and web services

Figure 6.1. The NetworkExplorer application you’ll build to cover networking topics

Figure 6.2. The output of the NetworkInfo toString method

Figure 6.3. The relationship between HttpClient, ResponseHandler, and Android Handler

Figure 6.4. The Delicious recent posts screen from the NetworkExplorer application

Chapter 7. Telephony

Figure 7.1. TelephonyExplorer main screen, along with the related activities the sample application performs

Figure 7.2. Displaying device and phone network meta-information obtained from TelephonyManager

Figure 7.3. An Android console session demonstrating the gsm command and available subcommands

Figure 7.4. An Activity that sends SMS messages

Chapter 8. Notifications and alarms

Figure 8.1. A simple Toast, the SMSNotifyExample, shown running in the emulator

Figure 8.2. Example of a Toast message being generated from an SMS message

Figure 8.3. Using the Android DDMS to send an SMS message to the application

Figure 8.4. The expanded SMS inbox displaying the contentIntent and appIntent

Figure 8.5. Example of the SimpleAlarm application running in the emulator

Figure 8.6. After the Alarm runs, the application shows a simple Toast message.

Chapter 9. Graphics and animation

Figure 9.1. A simple red rectangle drawn using Android’s Graphics API

Figure 9.2. Various shapes drawn using XML

Figure 9.3. Making a ball bounce using an Android XML animation

Figure 9.4. A simple animation of a globe bouncing in front of the Android logo

Figure 9.5. How two triangles are drawn from an array of vertices

Figure 9.6. A simple rectangle drawn on our surface using OpenGL ES

Figure 9.7. In OpenGL, a perspective is made up of a viewpoint and near (N), far (F), left (L), right (R), top (T), and bottom (B) clipping planes.

Figure 9.8. A 3D cube rotating in space

Chapter 10. Multimedia

Figure 10.1. OpenCORE’s services and architecture

Figure 10.2. Simple media player example

Figure 10.3. Playing an MP4 video in the Android emulator

Figure 10.4. Test pattern coming from the emulator camera and displayed in the SimpleCamera application

Figure 10.5. The Android emulator shows placeholder images for each photo taken.

Figure 10.6. An example of audio files being saved to the SD card image in the emulator

Figure 10.7. Photograph of VideoCam application running on an HTC Hero 2.

Chapter 11. Location, location, location

Figure 11.1. Screens from the Wind and Waves location-aware application

Figure 11.2. Using the DDMS tool to send direct latitude and longitude coordinates to the emulator as a mock location

Figure 11.3. Latitude and longitude spherical diagram, showing positive north and east and negative south and west

Figure 11.4. Using the DDMS tool with a GPX file to send mock location information

Figure 11.5. Using the DDMS tool with a KML file to send mock location information

Figure 11.6. The MapViewActivity from the Wind and Waves application shows a MapActivity with MapView.

Figure 11.7. The MapViewActivity from the Wind and Waves application using satellite mode

Figure 11.8. Geocoder example turning a String into an Address object that provides latitude and longitude coordinates

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

Figure 12.1. Data flows between the home office and a mobile worker

Figure 12.2. The field service application and dispatchers both leverage server-side transactions.

Figure 12.3. This figure depicts the basic flow of the field service application.

Figure 12.4. Resource files used in the sample application

Figure 12.5. The splash screen

Figure 12.6. The home screen. Less is more.

Figure 12.7. Settings screen in use

Figure 12.8. The ProgressDialog in use during RefreshJobs

Figure 12.9. ManageJobs Activity lists downloaded jobs.

Figure 12.10. An example of a job shown in the ShowJob Activity

Figure 12.11. Viewing a job address in the Maps application

Figure 12.12. Get Product Info takes the user to a web page specific to this job.

Figure 12.13. The CloseJob Activity capturing a signature and sending data to the server

Figure 12.14. The server-side dispatcher screen

Chapter 13. Building Android applications in C

Figure 13.1. Android runs atop a Linux kernel.

Figure 13.2. The build, copy, run cycle

Figure 13.3. Available libraries in /system/lib

Figure 13.4. Android libraries pulled to the development machine

Figure 13.5. Hello Android, static and dynamically linked

Figure 13.6. A better-behaving dynamic version of Hello Android

Figure 13.7. Interact with SQLite 3 from the command line in the adb shell.

Figure 13.8. The SQLite database on the development machine

Figure 13.9. DayTime Server running in the shell

Figure 13.10. The Daytime Client app

Figure 13.11. Testing the Daytime Client

Chapter 14. Bluetooth and sensors

Figure 14.1. Bluetooth settings screen

Figure 14.2. Options for a paired device

Figure 14.3. LEGO controller prompts for a PIN

Figure 14.4. Pairing with the LEGO robot

Figure 14.5. Simple LEGO NXT robot with motors connected to B and C ports

Figure 14.6. Waiting to connect to a robot

Figure 14.7. Connected to the robot with the motors stopped

Figure 14.8. Both motors are moving backward.

Figure 14.9. Spinning to the left

Figure 14.10. Disconnected state, waiting for a new connection

Chapter 15. Integration

Figure 15.1. Making entries in the native Contacts application

Figure 15.2. Fixed-length storage records

Figure 15.3. Open-ended storage records

Figure 15.4. Querying the contacts database

Figure 15.5. Combining raw contact data into unique contacts

Figure 15.6. Joining and separating contacts

Figure 15.7. Partially complete contact requested by application

Figure 15.8. Synchronizing data across multiple terminals

Figure 15.9. Retrying a synchronization operation after initial failure

Figure 15.10. Managing accounts

Figure 15.11. Managing multiple accounts

Figure 15.12. Login screen for LinkedIn account

Figure 15.13. A contact with standard and LinkedIn data

Figure 15.14. Choosing whether to display all LinkedIn contacts

Chapter 16. Android web development

Figure 16.1. Simple web page

Figure 16.2. The viewport tag modifies the appearance of the web page.

Figure 16.3. Scaled-up web page

Figure 16.4. Facebook mobile

Figure 16.5. The sample SQL application

Figure 16.6. Saving a new record

Figure 16.7. Listing the records from the table

Figure 16.8. Confirming deletion of records

Figure 16.9. Testing in the WebKit browser

Figure 16.10. index.html used in our sample application

Figure 16.11. index.html in our browser control

Figure 16.12. Entering a phone number in the web page

Figure 16.13. Ready to dial!

Figure 16.14. The Info button shows a Toast notification.

Figure 16.15. The toString method called from JavaScript

Figure 16.16. A crashed application thanks to the wait function

Figure 16.17. Setting up a search term

Figure 16.18. Searching the web via Google

Figure 16.19. Hit indicator

Chapter 17. AppWidgets

Figure 17.1. Power Control Widget on the home screen

Figure 17.2. Add to home screen

Figure 17.3. Choose a widget, any widget.

Figure 17.4. Tweeting about this chapter!

Figure 17.5. Four instances of the SiteMonitor AppWidget on the home screen

Figure 17.6. Site details, including hot-linked text

Figure 17.7. Easy dialing to an affected user

Figure 17.8. Monitor the good news also—revenue!

Figure 17.9. Architectural diagram of the SiteMonitor application

Figure 17.10. SiteMonitorWidget in Eclipse

Chapter 18. Localization

Figure 18.1. English locales on Android emulator

Figure 18.2. On-device locale options

Figure 18.3. Date and time settings

Figure 18.4. en_US locale

Figure 18.5. es_ES locale

Figure 18.6. Multiple strings.xml files

Figure 18.7. Localized screen referencing strings directly in layout

Figure 18.8. Localized menu

Figure 18.9. A job list in English

Figure 18.10. Job listings screen in en_US locale

Figure 18.11. Job listings screen in es_ES locale

Figure 18.12. Speedbumps in localization: OPEN status

Chapter 19. Android Native Development Kit

Figure 19.1. NDK on the disk

Figure 19.2. Application waiting to take photo

Figure 19.3. Take a photograph.

Figure 19.4. Captured image before image processing

Figure 19.5. Showing the edges of the car

Figure 19.6. A project in the Eclipse GUI

Figure 19.7. Building the JNI library

Figure 19.8. Project properties

Figure 19.9. External tool properties

Figure 19.10. Request refresh after build

Figure 19.11. Configuring build options

Appendix A. Installing the Android SDK

Figure A.1. The java –version command displays the version of Java installed on your computer

Figure A.2. Eclipse projects are stored in a workspace, which is a directory on your computer’s hard drive.

Figure A.3. Eclipse defaults to the home screen. Go to the workbench.

Figure A.4. Android development takes place in the Java Perspective.

Figure A.5. Unzip the Android SDK archive to your hard drive.

Figure A.6. The packages available for download

Figure A.7. The currently installed packages

Figure A.8. Defining an Android virtual device, also known as an emulator

Figure A.9. The Eclipse environment supports an extensible plug-in architecture.

Figure A.10. Choose the new features option.

Figure A.11. Create a new update site to search for Android-related tools.

Figure A.12. You must select Android Tools for Eclipse to download and install.

Figure A.13. ADT plug-in for Eclipse preferences

Appendix B. Publishing applications

Figure B.1. Using Android Tools from the Eclipse/ADT environment to export an unsigned application archive package

Figure B.2. Managing Android Market applications

Figure B.3. Managing the APK file and screenshots

Figure B.4. Textual descriptions of application along with publication options

Figure B.5. The newly published application becomes available on the device in mere moments.

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

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