Tài liệu Android in Action pdf

662 2.1K 0
Tài liệu Android in Action pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

MANNING W. Frank Ableson Robi Sen Chris King C. Enrique Ortiz THIRD EDITION IN ACTION www.it-ebooks.info Android in Action Third Edition www.it-ebooks.info www.it-ebooks.info Android in Action Third Edition W. FRANK ABLESON ROBI SEN CHRIS KING C. ENRIQUE ORTIZ MANNING SHELTER ISLAND www.it-ebooks.info For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 261 Shelter Island, NY 11964 Email: orders@manning.com ©2012 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. Development editor: Troy Mott 20 Baldwin Road Copyeditors: Benjamin Berg, Tiffany Taylor PO Box 261 Typesetter: Dottie Marsico Shelter Island, NY 11964 Cover designer: Marija Tudor ISBN 9781617290503 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – MAL – 16 15 14 13 12 11 www.it-ebooks.info v brief contents PART 1 WHAT IS ANDROID? THE BIG PICTURE 1 1 ■ Introducing Android 3 2 ■ Android’s development environment 33 PART 2 EXERCISING THE ANDROID SDK 63 3 ■ User interfaces 65 4 ■ Intents and Services 102 5 ■ Storing and retrieving data 130 6 ■ Networking and web services 160 7 ■ Telephony 188 8 ■ Notifications and alarms 206 9 ■ Graphics and animation 226 10 ■ Multimedia 260 11 ■ Location, location, location 284 PART 3 ANDROID APPLICATIONS 309 12 ■ Putting Android to work in a field service application 311 13 ■ Building Android applications in C 356 www.it-ebooks.info BRIEF CONTENTSvi PART 4 THE MATURING PLATFORM 383 14 ■ Bluetooth and sensors 385 15 ■ Integration 405 16 ■ Android web development 439 17 ■ AppWidgets 472 18 ■ Localization 509 19 ■ Android Native Development Kit 524 20 ■ Activity fragments 545 21 ■ Android 3.0 action bar 560 22 ■ Drag-and-drop 579 www.it-ebooks.info vii contents preface xix acknowledgments xxi about this book xxiii about the cover illustration xxviii PART 1 WHAT IS ANDROID? THE BIG PICTURE 1 1 Introducing Android 3 1.1 The Android platform 4 1.2 Understanding the Android market 5 Mobile operators 5 ■ Android vs. the feature phones 6 Android vs. the smartphones 7 ■ Android vs. itself 8 Licensing Android 9 1.3 The layers of Android 10 Building on the Linux kernel 11 ■ Running in the Dalvik VM 12 1.4 The Intent of Android development 13 Empowering intuitive UIs 13 ■ Intents and how they work 14 1.5 Four kinds of Android components 17 Activity 17 ■ Service 18 ■ BroadcastReceiver 19 ContentProvider 22 www.it-ebooks.info CONTENTSviii 1.6 Understanding the AndroidManifest.xml file 24 1.7 Mapping applications to processes 26 1.8 Creating an Android application 26 1.9 Android 3.0 for tablets and smartphones 30 Why develop for Android tablets? 30 ■ What’s new in the Android 3.0 Honeycomb platform? 31 1.10 Summary 32 2 Android’s development environment 33 2.1 Introducing the Android SDK 34 Core Android packages 35 ■ Optional packages 36 2.2 Exploring the development environment 36 The Java perspective 37 ■ The DDMS perspective 39 Command-line tools 42 2.3 Building an Android application in Eclipse 45 The Android Project Wizard 45 ■ Android sample application code 46 ■ Packaging the application 52 2.4 Using the Android emulator 53 Setting up the emulated environment 54 ■ Testing your application in the emulator 58 2.5 Debugging your application 59 2.6 Summary 61 PART 2 EXERCISING THE ANDROID SDK 63 3 User interfaces 65 3.1 Creating the Activity 66 Creating an Activity class 68 ■ XML vs. programmatic layouts 69 ■ Exploring the Activity lifecycle 72 ■ The server connection 73 3.2 Working with views 75 Exploring common views 76 ■ Using a ListView 78 Multitasking with Handler and Message 82 ■ Creating custom views 83 ■ Understanding layout 86 ■ Handling focus 88 Grasping events 89 www.it-ebooks.info CONTENTS ix 3.3 Using resources 90 Supported resource types 90 ■ Referencing resources in Java 91 ■ Defining views and layouts through XML resources 93 ■ Externalizing values 95 ■ Providing animations 98 3.4 Exploring the AndroidManifest file 99 3.5 Summary 101 4 Intents and Services 102 4.1 Serving up RestaurantFinder with Intent 103 Defining Intents 103 ■ Implicit and explicit invocation 104 Adding external links to RestaurantFinder 105 ■ Finding your way with Intent 107 ■ Taking advantage of Android-provided activities 109 4.2 Checking the weather with a custom URI 110 Offering a custom URI 110 ■ Inspecting a custom URI 112 4.3 Checking the weather with broadcast receivers 114 Broadcasting Intent 114 ■ Creating a receiver 115 4.4 Building a background weather service 116 4.5 Communicating with the WeatherAlertService from other apps 120 Android Interface Definition Language 120 ■ Binder and Parcelable 122 ■ Exposing a remote interface 123 Binding to a Service 124 ■ Starting vs. binding 127 Service lifecycle 128 4.6 Summary 129 5 Storing and retrieving data 130 5.1 Using preferences 131 Working with SharedPreferences 131 ■ Preference access permissions 134 5.2 Using the filesystem 137 Creating files 137 ■ Accessing files 138 ■ Files as raw resources 139 ■ XML file resources 140 ■ External storage via an SD card 142 5.3 Persisting data to a database 145 Building and accessing a database 146 ■ Using the sqlite3 tool 150 www.it-ebooks.info [...]... Authenticating to LinkedIn Synchronizing to the backend with SyncAdapter The synchronizing lifecycle data 432 15.7 432 16 ■ 425 432 Synchronizing LinkedIn Wrapping up: LinkedIn in action 435 Finalizing the LinkedIn project Moving on 437 15.8 Telling ■ Summary 435 ■ Troubleshooting tips 436 437 Android web development 439 16.1 What’s Android web development? 440 Introducing WebKit options 441 16.2 440 ■ Examining... ■ Examining the architectural Optimizing web applications for Android 442 Designing with mobile in mind 442 Adding the viewport tag 444 Selectively loading content 446 Interrogating the user agent 446 The media query 447 Considering a madefor-mobile application 448 ■ ■ ■ ■ 16.3 ■ Storing data directly in the browser 449 Setting things up 450 Examining the code 451 The user interface 451 Opening the... Obtaining phone state Interacting with the phone 196 Using Intents to make calls 196 Using phone number–related utilities 198 Intercepting outbound calls 200 ■ ■ 7.5 Working with messaging: SMS 200 Sending SMS messages 7.6 8 Summary ■ Receiving SMS messages 205 Notifications and alarms 8.1 201 Introducing Toast 206 207 www.it-ebooks.info 204 xi CONTENTS 8.2 8.3 8.4 Placing your Toast message 209 Making... Looking at the NDK 526 527 Demonstrating the completed application project structure 529 19.3 Building an application with the NDK ■ Building the JNI library 528 Examining the 530 Understanding JNI 530 Implementing the library Compiling the JNI library 536 ■ 19.4 Building the user interface User interface layout edges 541 19.5 19.6 20 ■ 537 Taking a photo 539 ■ Finding the Integrating the NDK into... virtual machine (VM) Java programming skills are helpful throughout the book, but this chapter is more about setting the stage than about coding specifics One coding element introduced in this chapter is the Intent class Having a good understanding of and comfort level with the Intent class is essential for working with the Android platform In addition to Intent, this chapter introduces the four main application... xiv CONTENTS 15.2 15.3 Getting started with LinkedIn 411 Managing contacts 413 Leveraging the built -in Contacts app 413 Requesting operations from your app 416 Directly reading and modifying the contacts database 417 Adding contacts 418 ■ ■ ■ 15.4 Keeping it together 421 The dream of sync 421 Defining accounts secrets: The AccountManager service 423 422 ■ 15.5 Creating a LinkedIn account 424 Not friendly... Starting drag operations 586 Listening for drag-and-drop events 587 Responding to drag-start operations 588 Handling drop operations 589 Summary 590 Installing the Android SDK 591 Publishing applications 601 index 613 www.it-ebooks.info 575 574 www.it-ebooks.info preface The idea of a writing a book about Android development can be somewhat futile at times, considering the pace at which Android continues... www.it-ebooks.info ABOUT THIS BOOK xxv classes This chapter begins combining fundamental concepts with more real-world details, such as handling application state, using a database for persistent storage, and working with SQLite Chapter 6 deals with storing and retrieving data over the network Here we include a networking primer before delving into using raw networking concepts such as sockets on Android. .. demonstrates integrating with an external data source In particular, this application brings Android into the social-networking scene by integrating with the popular LinkedIn professional networking service Chapter 16 explores the world of web development Android s browser is based on the open source WebKit engine and brings desktop-like capability to this mobile browser This chapter equips you to bring attractive... the first edition, Unlocking Android, have been reused in the second and third editions of the book Although the title was changed to Android in Action during the writing of the second edition, we kept the original book title in our graphics and sample applications Author Online Purchase of Android in Action, Third Edition includes free access to a private web forum run by Manning Publications where . synchronizing lifecycle 432 ■ Synchronizing LinkedIn data 432 15.7 Wrapping up: LinkedIn in action 435 Finalizing the LinkedIn project 435 ■ Troubleshooting. Intents and Services 102 4.1 Serving up RestaurantFinder with Intent 103 Defining Intents 103 ■ Implicit and explicit invocation 104 Adding external links

Ngày đăng: 17/02/2014, 08:20

Từ khóa liên quan

Mục lục

  • Android in Action

  • brief contents

  • contents

  • preface

  • acknowledgments

  • about this book

    • Who should read this book?

    • Roadmap

      • Part 1: The essentials

      • Part 2: The programming environment

      • Part 3: Bringing it all together

      • Part 4: The maturing platform

      • Appendixes

    • Code conventions and downloads

    • Software requirements

    • A note about the graphics

    • Author Online

  • about the cover illustration

  • Part 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 Android 3.0 for tablets and smartphones

        • 1.9.1 Why develop for Android tablets?

        • 1.9.2 What’s new in the Android 3.0 Honeycomb platform?

      • 1.10 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

  • Part 2 Exercising the Android SDK

    • Chapter 3 User interfaces

      • 3.1 Creating the Activity

        • 3.1.1 Creating an Activity class

        • 3.1.2 XML vs. programmatic layouts

        • 3.1.3 Exploring the Activity lifecycle

        • 3.1.4 The server connection

      • 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 vs. 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 Phone or not?

      • 7.3 Accessing telephony information

        • 7.3.1 Retrieving telephony properties

        • 7.3.2 Obtaining phone state information

      • 7.4 Interacting with the phone

        • 7.4.1 Using Intents to make calls

        • 7.4.2 Using phone number–related utilities

        • 7.4.3 Intercepting outbound calls

      • 7.5 Working with messaging: SMS

        • 7.5.1 Sending SMS messages

        • 7.5.2 Receiving SMS messages

      • 7.6 Summary

    • Chapter 8 Notifications and alarms

      • 8.1 Introducing Toast

      • 8.2 Placing your Toast message

      • 8.3 Making a custom Toast view

      • 8.4 Introducing notifications

        • 8.4.1 The Notification class

        • 8.4.2 Notifying a user with a simple button press

      • 8.5 Making a custom notification view

      • 8.6 Introducing alarms

        • 8.6.1 Creating a simple alarm example

        • 8.6.2 Using notifications with alarms

      • 8.7 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 Introducing RenderScript for Android

        • 9.4.1 RenderScript advantages and disadvantages

        • 9.4.2 Building a RenderScript application

      • 9.5 Summary

    • Chapter 10 Multimedia

      • 10.1 Introduction to multimedia and Stagefright

        • 10.1.1 Stagefright overview

      • 10.2 Playing audio

      • 10.3 Playing video

      • 10.4 Capturing media

        • 10.4.1 Understanding the camera

        • 10.4.2 Capturing audio

        • 10.4.3 Recording video

      • 10.5 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

  • Part 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() vs. 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

  • Part 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

    • Chapter 20 Activity fragments

      • 20.1 Fragment lifecyle

      • 20.2 Creating fragments and fragment layouts

        • 20.2.1 Create the fragment subclass

        • 20.2.2 Defining a fragment layout

        • 20.2.3 Include the fragment within the activity

      • 20.3 Background fragments

      • 20.4 The fragment manager

      • 20.5 Fragment transactions

      • 20.6 Fragment back stack

      • 20.7 The Android Compatibility Package

      • 20.8 Summary

    • Chapter 21 Android 3.0 action bar

      • 21.1 Introducing the action bar

      • 21.2 Overview of the ActionBar classes

      • 21.3 Action bar display options

        • 21.3.1 Application name and icon

        • 21.3.2 Navigation modes

      • 21.4 Action items

        • 21.4.1 The application icon as an action item

        • 21.4.2 Action views

      • 21.5 Removing, showing, and hiding the action bar

      • 21.6 Action bar styling

      • 21.7 Summary

    • Chapter 22 Drag-and-drop

      • 22.1 The drag-and-drop classes

      • 22.2 Drag-and-drop operations

      • 22.3 The shadow builder

      • 22.4 Drag events

      • 22.5 Starting drag operations

      • 22.6 Listening for drag-and-drop events

      • 22.7 Responding to drag-start operations

      • 22.8 Handling drop operations

      • 22.9 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

    • Symbols

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    • J

    • K

    • L

    • M

    • N

    • O

    • P

    • Q

    • R

    • S

    • T

    • U

    • V

    • W

    • X

    • Z

Tài liệu cùng người dùng

Tài liệu liên quan