Tải bản đầy đủ (.pdf) (7 trang)

a0041 apress beginning android tablet programming nov 201 morebook vn 5726

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (123.4 KB, 7 trang )


Beginning Android Tablet
Programming
Starting with Android Honeycomb for Tablets

„„„
Robbie Matthews


Beginning Android Tablet Programming: Starting with Android Honeycomb for Tablets
Copyright © 2011 by Robbie Matthews
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-4302-3783-9
ISBN-13 (electronic): 978-1-4302-3784-6
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol
with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of
the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject
to proprietary rights.
President and Publisher: Paul Manning
Lead Editor: Steve Anglin and Tom Welsh
Technical Reviewer: Stephen Bull and Peter Brownlow
Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Morgan Engel,
Jonathan Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham,
Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic
Shakeshaft, Gwenan Spearing, Matt Wade, Tom Welsh
Coordinating Editor: Anita Castro


Copy Editor: Mary Ann Fugate
Compositor: Bytheway Publishing Services
Indexer: SPI Global
Artist: SPI Global
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail , or visit www.springeronline.com.
For information on translations, please e-mail , or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our
Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have
any liability to any person or entity with respect to any loss or damage caused or alleged to be caused
directly or indirectly by the information contained in this work.
The source code for this book is available to readers at www.apress.com. You will need to answer
questions pertaining to this book in order to successfully download the code.


I dedicate this book to my family. Without your support and occasional nagging
this book would never have been finished.
Robbie Matthews


Contents at a Glance
„ About the Author.................................................................................................. xiv
„ About the Technical Reviewer .............................................................................. xv
„ Acknowledgments ............................................................................................... xvi
„ Some Notes on Using the Downloaded Code ...................................................... xvii
„ Chapter 1: Getting Started ......................................................................................1

„ Chapter 2: How Android Works.............................................................................27
„ Chapter 3: What Can You Do with an Android Tablet?.........................................53
„ Chapter 4: Beyond Java: Programming in Python and Friends ............................79
„ Chapter 5: Project 1: Media Player .....................................................................105
„ Chapter 6: Explorer .............................................................................................123
„ Chapter 7: Contact Manager ...............................................................................151
„ Chapter 8: Dude, Where’s My Car? .....................................................................175
„ Chapter 10: Remind Me ......................................................................................221
„ Chapter 11: Everything Else................................................................................243
„ Index ...................................................................................................................269

iv


„ INDEX

Reflection, 133, 137
remapCoordinateSystem, 62
Remind Me, 221
Alarms
List Manager, 237, 238
manipulating Alarms Table, 239
contacts, 233, 234
enhancing the application, 241
main screen, 231, 232
onscreen keyboard, 232, 233
responding to Alarm, 235–237
setting Reminder Alarm, 234, 235
testing TTS, 240, 241
Runnable, 244


„S
savedInstanceState, 33
scaledDensity, 155
Scripting Layer for Android (SL4A), 79, 80.
See also Script management
Script management, 80
battery management, 97–99
contacts and phone numbers, 102–
103
control phone settings, 94–95
editing, 100–101
events, 89–90
Facades, 82–83
hello_world script, 81
Intent, 83–86
location function, 95–97
media files, 91–94
Prompt, and Help, 82
Python help system, 82
sample programs, 81
SQL, 103
user interaction, 86–88
WakeLock commands, 99–100
SeekBar, 121, 122
SENSOR_DELAY_NORMAL, 59
Sensors
accessing SensorManager, 56
Button Click Events, 60
getting orientation, 61–62

onListClick Event, 56
Portrait Mode, 61
screen layout, 54–55
SensorEventListener, 58
testing, 55

types, 54
Values, 60–61
Services, 187–188
Share My Stuff, 75–77
SharedPreferences, 41
shouldOverrideUrlLoading, 69
SimpleCursorAdapter, 114
SMS
receiving, 224
sending, 223–224
SmsManager, 223
SmsReceiver, 225
SQLite
creating database, 228
definition, 227
getting database, 229
using database, 229, 230
SQLite3, 104
SQLiteOpenHelper, 228
startActivityForResult, 64
static member, 14, 15
staticVariable, 15, 17
StringBuffer and StringBuilder, 21
SurfaceHolder, 121, 204–207

swapCursor, 120

„T
Target
code for ManageList, 195–196
edit dialog, 196–197
TableLayout, 194–195
Target class, 193–194
target editor, 196
TextPaint, 155
Text To Speech (TTS)
queues, 227
SMSReceiveService Class, 225–226
TextView, 32
Threads
Android Threads, 203
concepts of, 199
Java Threads, 200–203
Three dimensional graphics
BA3TPOpenGl, 214
GLSurfaceView implementation, 215
initializing 3D environment, 216,
217
interprocess communication, 219,
220

273


„ INDEX


Three dimensional graphics (cont.)
MainActivity for 3D demo, 216
MainActivity onCreate event, 219
onDrawFrame event, 218
onSurfaceChanged event, 218
onSurfaceCreated event, 217
spinning box, 214
TickerText, 188
Timers, 243
Handler, 244
Handler.postAtTime with token,
246
Handler.PostDelayed, 245
implementing real-time clock, 245,
246
stopping gracefully, 246
Toast, 34
toString(), 24
Touch Events, 209
TreeMap. IdentityHashMap, 22
Tricorder, 54

274

„U
Uri.withAppendedPath, 117
USB, 262
device filter, 266
in action, 267

list of devices, 263–264
responding to a plugged device, 266
responding to an unplugged device, 265–266
simple activity, 263
Thread to read from, 265

„V
varargs, 248

„ W, X, Y, Z
Wakeup Calls, 186
WeakHashMap, 23



×