Programming Android (2nd ed.) [Mednieks, Dornin, Meike & Nakamura 2012-10-22] (early release).pdf
(
8417 KB
)
Pobierz
SECOND EDITION
Programming Android
Zigurd Mednieks, Laird Dornin, G. Blake Meike, and Ma-
sumi Nakamura
Beijing
Cambridge
Farnham
Köln
Sebastopol
Tokyo
•
•
•
•
•
Programming Android, Second Edition
by Zigurd Mednieks, Laird Dornin, G. Blake Meike, and Masumi Nakamura
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
.
Proofreader:
Sada Preisch
Interior Designer:
David Futato
Illustrator:
Rebecca Demarest
Revision History for the :
2012-03-09 Early release revision 1
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
, the 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]
1331160433
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Part I.
Tools and Basics
1.
Installing the Android SDK and Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Installing the Android SDK and Prerequisites
3
The Java Development Kit (JDK)
4
The Eclipse Integrated Development Environment (IDE)
5
The Android SDK
7
Adding Build Targets to the SDK
8
The Android Development Toolkit (ADT) Plug-in for Eclipse
9
Test Drive: Confirm That Your Installation Works
13
Making an Android Project
13
Making an Android Virtual Device (AVD)
16
Running a Program on an AVD
19
Running a Program on an Android Device
20
Troubleshooting SDK Problems: No Build Targets
21
Components of the SDK
21
The Android Debug Bridge (adb)
21
The Dalvik Debug Monitor Server (DDMS)
21
Components of the ADT Eclipse Plug-in
23
Android Virtual Devices
25
Other SDK Tools
26
Keeping Up-to-Date
28
Keeping the Android SDK Up-to-Date
28
Keeping Eclipse and the ADT Plug-in Up-to-Date
29
Keeping the JDK Up-to-Date
29
Example Code
30
SDK Example Code
30
Example Code from This Book
30
On Reading Code
32
iii
2.
Java for Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Android Is Reshaping Client-Side Java
33
The Java Type System
34
Primitive Types
34
Objects and Classes
35
Object Creation
35
The Object Class and Its Methods
37
Objects, Inheritance, and Polymorphism
39
Final and Static Declarations
41
Abstract Classes
45
Interfaces
46
Exceptions
48
The Java Collections Framework
52
Garbage Collection
55
Scope
56
Java Packages
56
Access Modifiers and Encapsulation
57
Idioms of Java Programming
59
Type Safety in Java
59
Using Anonymous Classes
62
Modular Programming in Java
65
Basic Multithreaded Concurrent Programming in Java
68
Synchronization and Thread Safety
68
Thread Control with wait() and notify() Methods
71
Synchronization and Data Structures
73
3.
The Ingredients of an Android Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Traditional Programming Models Compared to Android
75
Activities, Intents, and Tasks
77
Other Android Components
79
Service
79
Content Providers
79
BroadcastReceiver
83
Component Life Cycles
83
The Activity Life Cycle
83
On Porting Software to Android
85
Static Application Resources and Context
86
Organizing Java Source
87
Resources
88
Application Manifests
90
Initialization Parameters in AndroidManifest.xml
91
Packaging an Android Application: The .apk File
94
The Android Application Runtime Environment
94
iv
|
Table of Contents
Plik z chomika:
musli_com
Inne pliki z tego folderu:
100 Questions and Answers to Help You Land Your Dream Android Job_ or to Hire the Right Candidate! [López-Mañas 2015-07-19](1).pdf
(742 KB)
20 Recipes for Programming PhoneGap_ Cross-Platform Mobile Development for Android and iPhone [Munro 2012-04-06](1).pdf
(6551 KB)
50 Android Hacks [Sessa 2013-06-13](2).pdf
(10631 KB)
A Guide to Android for Seniors_ Introduction to Android Phones and Tablets [Hollinder 2015-04-02](1).pdf
(336 KB)
Advanced Android 4 Games [Silva 2011-12-19](1).pdf
(7341 KB)
Inne foldery tego chomika:
3D Design - Programming
ActionScript
Actionscript - Flash - Flex - Air
Ada
ADO
Zgłoś jeśli
naruszono regulamin