Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Professional Android 2 Application Development
Nội dung xem thử
Mô tả chi tiết
Join the discussion @ p2p.wrox.com Wrox Programmer to Programmer™
Written by an Android authority, this up-to-date resource shows you
how to leverage the features of Android 2 to enhance existing
products or create innovative new ones. Serving as a hands-on guide
to building mobile apps using Android, the book walks you through
a series of sample projects that introduces you to Android’s new features
and techniques. Using the explanations and examples included in
these pages, you’ll acquire the foundation needed to write compelling
mobile applications that use Android, along with the flexibility to
quickly adapt to future enhancements.
Professional Android 2 Application Development:
• Reviews Android as a development platform and best practices
for mobile development
• Provides an in-depth look at the Android application components
• Details creating layouts and Views to produce compelling resolution
independent user interfaces
• Examines Intents and Content Providers for sharing data
• Introduces techniques for creating map-based applications and using
location-based services such as GPS
• Looks at how to create and use background Services, Notifications,
and Alarms
• Demonstrates how to create interactive homescreen components
• Explores the Bluetooth, telephony, and networking APIs
• Examines using hardware, including the camera and sensors such
as the compass and accelerometers
Reto Meier is a software developer who has been involved in Android since the
initial release in 2007. He is an Android Developer Advocate at Google.
Wrox Professional guides are planned and written by working programmers
to meet the real-world needs of programmers, developers, and IT professionals.
Focused and relevant, they address the issues technology professionals face every
day. They provide examples, practical solutions, and expert education in new
technologies, all designed to help programmers do a better job.
Programming / Mobile & Wireless / Android
Build unique mobile applications
with the latest Android SDK
wrox.com
Programmer
Forums
Join our Programmer to
Programmer forums to ask
and answer programming
questions about this book,
join discussions on the
hottest topics in the industry,
and connect with fellow
programmers from around
the world.
Code Downloads
Take advantage of free code
samples from this book, as
well as code samples from
hundreds of other books, all
ready to use.
Read More
Find articles, ebooks, sample
chapters and tables of contents
for hundreds of books, and
more reference resources on
programming topics that matter
to you.
$44.99 USA
$53.99 CAN
Meier Android™ 2 Application Development
Reto Meier
Professional
Android™
2
Application Development
Professional
Related Wrox Books
Beginning iPhone SDK Programming with Objective-C
ISBN: 9780470500972
Learning to develop iPhone applications doesn’t need to be an overwhelming undertaking. This book provides an easy-to-follow,
example-driven introduction to the fundamentals of the Apple iPhone SDK and offers you a clear understanding of how things
are done when programming iPhone applications with Objective-C. When you reach the end of the book, you will be prepared to
confidently tackle your next iPhone programming challenge.
Ivor Horton’s Beginning Java 2: JDK 5 Edition
ISBN: 978-0-7645-6874-9
This comprehensive introduction to Java programming — written by the leading author of computer programming language
tutorials — shows readers how to build real-world Java applications using the Java SDK (software development kit).
Safari and WebKit Development for iPhone OS 3.0
ISBN: 9780470549667
With the unparalleled success of iPhone and iPod touch, iPhone OS 3.0 has emerged as a compelling platform for which vast
numbers of web developers are designing and building web-based mobile applications. This book explores the Safari and WebKit
development platform that is built into iPhone OS 3.0 and takes you through the process of creating an iPhone web application
from the ground up. You’ll learn how to use existing open source frameworks to speed up your development time, imitate qualities
of built-in Apple apps, cache data locally and even run in offline mode, and more. Whether you’re eager to build new web applications
for iPhone OS 3.0 or optimize existing web sites for this platform, you have everything you need to do so within this book.
Get more out of
wrox.com
Programmer to Programmer™
Interact
Take an active role online by participating in our
P2P forums @ p2p.wrox.com
Wrox Online Library
Hundreds of our books are available online
through Books24x7.com
Wrox Blox
Download short informational pieces and code
to keep you up to date and out of trouble!
Join the Community
Sign up for our free monthly newsletter at
newsletter.wrox.com
Browse
Ready for more Wrox? We have books and
e-books available on .NET, SQL Server, Java,
XML, Visual Basic, C#/ C++, and much more!
Contact Us.
We always like to get feedback from our readers. Have a book idea?
Need community support? Let us know by e-mailing [email protected]
PROFESSIONAL
ANDROID™ 2 APPLICATION DEVELOPMENT
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
CHAPTER 1 Hello, Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
CHAPTER 2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
CHAPTER 3 Creating Applications and Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
CHAPTER 4 Creating User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
CHAPTER 5 Intents, Broadcast Receivers, Adapters,
and the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
CHAPTER 6 Files, Saving State, and Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
CHAPTER 7 Databases and Content Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
CHAPTER 8 Maps, Geocoding, and Location-Based Services . . . . . . . . . . . . . . . . . 245
CHAPTER 9 Working in the Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
CHAPTER 10 Invading the Phone-Top . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
CHAPTER 11 Audio, Video, and Using the Camera . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
CHAPTER 12 Telephony and SMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
CHAPTER 13 Bluetooth, Networks, and Wi-Fi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
CHAPTER 14 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
CHAPTER 15 Advanced Android Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
PROFESSIONAL
Android™ 2 Application Development
Reto Meier
Wiley Publishing, Inc.
Professional Android™ 2 Application Development
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
ISBN: 978-0-470-56552-0
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the
1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978)
750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department,
John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at
http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to
the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation
warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The
advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the
publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the
services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages
arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of
further information does not mean that the author or the publisher endorses the information the organization or Web site may
provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have
changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the United
States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in
electronic books.
Library of Congress Control Number: 2009943638
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries,
and may not be used without written permission. Android is a trademark of Google, Inc. All other trademarks are the property
of their respective owners. Wiley Publishing, Inc. is not associated with any product or vendor mentioned in this book.
To Kristy
ABOUT THE AUTHOR
RETO MEIER is originally from Perth, Western Australia, but now lives in London.
He currently works as an Android Developer Advocate at Google, helping Android app developers create the best applications possible. Reto is an experienced software developer with more than
10 years of experience in GUI application development. Before Google, he worked in various industries, including offshore oil and gas and finance.
Always interested in emerging technologies, Reto has been involved in Android since the initial
release in 2007. In his spare time, he tinkers with a wide range of development platforms, including
Google’s plethora of developer tools.
You can check out Reto’s web site, The Radioactive Yak, athttp://blog.radioactiveyak.com or
follow him on twitter at http://www.twitter.com/retomeier.
ABOUT THE TECHNICAL EDITOR
MILAN NARENDRA SHAH graduated with a BSc Computer Science degree from the University of
Southampton. He has been working as a software engineer for more than seven years, with
experiences in C#, C/C++, and Java. He is married and lives in Buckinghamshire, United Kingdom.
CREDITS
ACQUISITIONS EDITOR
Scott Meyers
PROJECT EDITOR
William Bridges
TECHNICAL EDITOR
Milan Narendra Shah
PRODUCTION EDITOR
Rebecca Anderson
COPY EDITOR
Sadie Kleinman
EDITORIAL DIRECTOR
Robyn B. Siesky
EDITORIAL MANAGER
Mary Beth Wakefield
ASSOCIATE DIRECTOR OF MARKETING
David Mayhew
PRODUCTION MANAGER
Tim Tate
VICE PRESIDENT AND EXECUTIVE GROUP
PUBLISHER
Richard Swadley
VICE PRESIDENT AND EXECUTIVE PUBLISHER
Barry Pruett
ASSOCIATE PUBLISHER
Jim Minatel
PROJECT COORDINATOR, COVER
Lynsey Stanford
PROOFREADER
Kyle Schlesinger, Word One
INDEXER
Robert Swanson
COVER IMAGE
© Linda Bucklin/istockphoto
COVER DESIGNER
Michael E. Trent
ACKNOWLEDGMENTS
Most importantly I’d like to thank Kristy. Your support makes everything I do possible, and your
generous help ensured that this book was the best it could be. Without you it would never have
happened.
A big thank-you goes to Google and the Android team, particularly the Android engineers and my
colleagues in developer relations. The pace at which Android has grown and developed in the past
year is nothing short of phenomenal.
I also thank Scott Meyers for giving me the chance to bring this book up to date; and Bill Bridges,
Milan Shah, Sadie Kleinman, and the Wrox team for helping get it done.
Special thanks go out to the Android developer community. Your hard work and exciting applications have helped make Android a great success.
CONTENTS
INTRODUCTION xxvii
CHAPTER 1: HELLO, ANDROID 1
A Little Background 2
The Not-So-Distant Past 2
The Future 3
What It Isn’t 3
Android: An Open Platform for Mobile Development 4
Native Android Applications 5
Android SDK Features 6
Access to Hardware, Including Camera, GPS, and Accelerometer 6
Native Google Maps, Geocoding, and Location-Based Services 7
Background Services 7
SQLite Database for Data Storage and Retrieval 7
Shared Data and Interapplication Communication 7
Using Widgets, Live Folders, and Live Wallpaper to Enhance the
Home Screen 8
Extensive Media Support and 2D/3D Graphics 8
Optimized Memory and Process Management 8
Introducing the Open Handset Alliance 9
What Does Android Run On? 9
Why Develop for Mobile? 9
Why Develop for Android? 10
What Has and Will Continue to Drive Android Adoption? 10
What Does It Have That Others Don’t? 11
Changing the Mobile Development Landscape 11
Introducing the Development Framework 12
What Comes in the Box 12
Understanding the Android Software Stack 13
The Dalvik Virtual Machine 14
Android Application Architecture 15
Android Libraries 16
Summary 16