Programming Android (2nd Edition).pdf

(13323 KB) Pobierz
SECOND EDITION
Programming Android
Zigurd Mednieks, Laird Dornin, G. Blake Meike,
and Masumi Nakamura
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Tokyo
Programming Android, Second Edition
by Zigurd Mednieks, Laird Dornin, G. Blake Meike, and Masumi Nakamura
Copyright © 2012 Zigurd Mednieks, Laird Dornin, Blake Meike, and Masumi Nakamura. All rights
reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or
corporate@oreilly.com.
Editors:
Andy Oram and Rachel Roumeliotis
Production Editor:
Melanie Yarbrough
Copyeditor:
Audrey Doyle
Proofreader:
Teresa Horton
September 2012:
Second Edition.
Indexer:
Ellen Troutman-Zaig
Cover Designer:
Karen Montgomery
Interior Designer:
David Futato
Illustrator:
Robert Romano
Revision History for the Second Edition:
2012-09-26
First release
See
http://oreilly.com/catalog/errata.csp?isbn=9781449316648
for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc.
Programming Android, Second Edition,
the cover image of a pine grosbeak, and
related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-1-449-31664-8
[LSI]
1348682639
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Part I. Tools and Basics
1. Installing the Android SDK and Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Installing the Android SDK and Prerequisites
The Java Development Kit (JDK)
The Eclipse Integrated Development Environment (IDE)
The Android SDK
Adding Build Targets to the SDK
The Android Developer Tools (ADT) Plug-in for Eclipse
Test Drive: Confirm That Your Installation Works
Making an Android Project
Making an Android Virtual Device (AVD)
Running a Program on an AVD
Running a Program on an Android Device
Troubleshooting SDK Problems: No Build Targets
Components of the SDK
The Android Debug Bridge (adb)
The Dalvik Debug Monitor Server (DDMS)
Components of the ADT Eclipse Plug-in
Android Virtual Devices
Other SDK Tools
Keeping Up-to-Date
Keeping the Android SDK Up-to-Date
Keeping Eclipse and the ADT Plug-in Up-to-Date
Keeping the JDK Up-to-Date
Example Code
SDK Example Code
Example Code from This Book
On Reading Code
3
4
5
7
8
9
12
12
16
19
20
21
21
21
21
23
25
26
27
28
28
29
30
30
30
31
iii
Zgłoś jeśli naruszono regulamin