)
*+,
-.//0123 256
78910:9 ;<=
->?@
9
8
! #$ % &'(
0110234567
The Busy Coder's Guide to Android
Development
by Mark L. Murphy
The Busy Coder's Guide to Android Development
by Mark L. Murphy
Copyright © 2008-2011 CommonsWare, LLC. All Rights Reserved.
Printed in the United States of America.
CommonsWare books may be purchased in printed (bulk) or digital form for educational or
business use. For more information, contact
Printing History:
Mar 2011:Version 3.6
ISBN: 978-0-9816780-0-9
The CommonsWare name and logo, “Busy Coder's Guide”, and related trade dress are
trademarks of CommonsWare, LLC.
All other trademarks referenced in this book are trademarks of their respective firms.
The publisher and author(s) assume no responsibility for errors or omissions or for damages
resulting from the use of the information contained herein.
Table of Contents
Welcome to the Warescription!. ......................................................xxiii
Preface. ...............................................................................................xxv
Welcome to the Book!..............................................................................xxv
Warescription. ..........................................................................................xxv
Book Bug Bounty. ....................................................................................xxvi
Source Code And Its License. ................................................................xxvii
Creative Commons and the Four-to-Free (42F) Guarantee...............xxviii
Acknowledgments. ..................................................................................xxix
The Big Picture. ......................................................................................1
What Androids Are Made Of.......................................................................3
Activities. ................................................................................................3
Services. ..................................................................................................4
Content Providers. .................................................................................4
Intents. ....................................................................................................4
Stuff At Your Disposal. .................................................................................5
Storage. ...................................................................................................5
Network. .................................................................................................5
Multimedia. ............................................................................................5
GPS. .........................................................................................................5
iii
Phone Services. ......................................................................................6
The Big Picture...Of This Book....................................................................6
How To Get Started. ...............................................................................7
Step #1: Java. ..................................................................................................7
Install the JDK. .......................................................................................7
Learn Java. ..............................................................................................8
Step #2: Install the Android SDK. ...............................................................9
Install the Base Tools.............................................................................9
Install the SDKs and Add-Ons..............................................................9
Step #3: Install the ADT for Eclipse. ..........................................................13
Step #4: Install Apache Ant. .......................................................................15
Step #5: Set Up the Emulator. ....................................................................16
Step #6: Set Up the Device.........................................................................23
Windows...............................................................................................24
OS X and Linux.....................................................................................25
Your First Android Project. ..................................................................27
Step #1: Create the New Project.................................................................27
Eclipse. ..................................................................................................27
Command Line......................................................................................31
Step #2: Build, Install, and Run the Application in Your Emulator or
Device. .........................................................................................................32
Eclipse. ..................................................................................................32
Command Line. ....................................................................................33
Examining Your First Project. ..............................................................37
Project Structure.........................................................................................37
Root Contents.......................................................................................37
The Sweat Off Your Brow. ...................................................................38
iv
Keyword Index
size()
577
android collapseColumns
114
start()
177
android columnWidth
141
android completionThreshold
145
startActivity() 240, 241, 287, 397, 451, 506, 588,
591
android digits
startActivityForResult()
83
240-242, 287, 288, 511
android drawSelectorOnTop
startDownload()
android horizontalSpacing
startForeground()
141
520, 546, 547
android id
startPlayer()
138, 149
491
73, 74, 88, 105, 181, 182
522
android label
42
startService() 505-508, 511, 514, 516, 517, 519, 520,
522 stop()
177, 520, 547
android layout_above
106
stopForeground()
android layout_alignBaseline
107
546-548
stopPlayer()
522
android layout_alignBottom
106
stopSelf()
508
android layout_alignLeft
106
android layout_alignParentBottom
105
android layout_alignParentLeft
105
android layout_alignParentRight
105
stopService()
507, 509, 522
switch()
211
toggle()
85, 88, 196
toggleSatellite()
580
android layout_alignParentTop
105
toString()
132
android layout_alignRight
107
unbindService()
508, 509
android layout_alignTop
106, 107
unlock()
196
android layout_below
106
unregisterReceiver()
283
android layout_centerHorizontal
105
update()
462, 463
android layout_centerInParent
105
updateForecast()
483, 528
android layout_centerVertical
105
android layout_column
112
updateLabel()
174
updateTime()
67, 68
android layout_gravity
96
92
android layout_height
73, 95
valueOf()
Property. ........................................
android autoText
83
android capitalize
83
android layout_span
112
android layout_toLeftOf
106
android layout_toRightOf
106
android layout_weight
android layout_width
697
95
73, 95, 98
Keyword Index
android:manifest................................................41
android:spacing................................................149
android:name. ....................................42, 505, 552
android:spinnerSelector. .................................149
android:nextFocusDown. .................................90
android:src. ........................................................82
android:nextFocusLeft......................................90
android:stretchColumns...................................113
android:nextFocusRight. ..................................90
android:stretchMode........................................141
android:nextFocusUp. ......................................90
android:text..................................................73, 79
android:numColumns. .....................................141
android:textColor........................................80, 85
android:orientation...........................................94
android:textStyle. ........................................79, 83
android:permission. ................................506, 554
android:typeface................................................79
android:shrinkColumns. ..................................114
android:verticalSpacing. ..................................141
android:singleLine.............................................83
android:visibility. ..............................................90
698
Download from Wow! eBook <www.wowebook.com>