p. 1
/0112345 6783298 9 8 0110234567
[close]
p. 2
the busy coder s guide to advanced android development by mark l murphy
[close]
p. 3
the busy coder s guide to advanced android development by mark l murphy copyright © 2009-11 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 direct@commonsware.com printing history mar 2011:version 1.9.2 isbn 978-0-9816780-1-6 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 authors assume no responsibility for errors or omissions or for damages resulting from the use of the information contained herein.
[close]
p. 4
table of contents welcome to the warescription xix preface xxi welcome to the book xxi prerequisites xxi warescription xxiii errata and the book bug bounty xxiii source code xxv creative commons and the four-to-free 42f guarantee xxv lifecycle of a commonsware book xxvi webview inside and out 1 friends with benefits 1 turnabout is fair play 7 crafting your own views 13 pick your poison 13 colors mixed how you like them 15 the layout 16 the attributes 18 the class 19 seeing it in use 24 iii
[close]
p. 5
more fun with listviews 27 giant economy-size dividers 27 choosing what is selectable 28 introducing mergeadapter 29 lists via merges 30 how mergeadapter does it 33 from head to toe 36 control your selection 39 create a unified row view 40 configure the list get control on selection 41 change the row 43 stating your selection 45 creating drawables 47 traversing along a gradient 47 state law 51 a stitch in time saves nine 53 the name and the border 54 padding and the box 54 stretch zones 55 tooling 56 using nine-patch images 58 home screen app widgets 63 east is east and west is west 64 the big picture for a small app widget 64 crafting app widgets 65 the manifest 66 the metadata 67 iv
[close]
p. 6
the layout 68 the broadcastreceiver 68 the result 71 another and another 72 app widgets their life and times 73 controlling your app widget s destiny 73 change your look 74 one size may not fit all 76 advanced app widgets on android 3.x 76 new widgets for app widgets 77 preview images 78 adapter-based app widgets 79 being a good host 90 interactive maps 91 get to the point 92 getting the latitude and longitude 92 getting the screen position 92 not-so-tiny bubbles 94 options for pop-up panels 95 defining a panel layout 95 creating a popuppanel class 97 showing and hiding the panel 97 tying it into the overlay 99 sign sign everywhere a sign 105 selected states 105 per-item drawables 106 changing drawables dynamically 107 v
[close]
p. 7
in a new york minute or hopefully a bit faster 111 a little touch of noo yawk 114 touch events 114 finding an item 116 dragging the item 118 creating custom dialogs and preferences 121 your dialog chocolate-covered 121 basic alertdialog setup 123 handling color changes 125 state management 125 preferring your own preferences preferably 126 the constructors 127 creating the view 127 dealing with preference values 128 using the preference 131 animating widgets 135 it s not just for toons anymore 135 a quirky translation 136 mechanics of translation 136 imagining a sliding panel 137 the aftermath 137 introducing slidingpanel 138 using the animation 140 fading to black or some other color 140 alpha numbers 141 animations in xml 141 using xml animations 142 vi
[close]
p. 8
when it s all said and done 142 loose fill 143 hit the accelerator 144 animate set match 145 active animations 146 using the camera 149 sneaking a peek 149 the permission and the feature 150 the surfaceview 151 the camera 152 image is everything 155 asking for a camera maybe 156 getting the camera 157 asking for a format 160 taking a picture 160 using asynctask 162 maintaining your focus 163 all the bells and whistles 164 playing media 165 get your media on 165 making noise 166 moving pictures 172 pictures in the stream 176 rules for streaming 177 establishing the surface 178 floating panels 179 playing video 181 vii
[close]
p. 9
touchable controls 183 other ways to make noise 185 soundpool 186 audiotrack 187 tonegenerator 187 handling system events 191 get moving first thing 191 the permission 192 the receiver element 192 the receiver implementation 193 i sense a connection between us 194 feeling drained 197 sticky intents and the battery 201 other power triggers 202 advanced service patterns 203 remote services 203 when ipc attacks 204 a consumer economy 206 service from afar 208 servicing the service 214 the bind that fails 220 if the binding is too tight 221 alarmmanager making the services run on time 223 the wakefulintentservice pattern 223 the how and why of wakefulintentservice 228 background data setting 232 the everlasting service anti-pattern 233 viii
[close]
p. 10
using system settings and services 235 setting expectations 235 basic settings 235 secure settings 239 can you hear me now ok how about now 240 attaching seekbars to volume streams 241 putting stuff on the clipboard 244 using the clipboard on android 1.x/2.x 244 advanced clipboard on android 3.x 248 the rest of the gang 253 content provider theory 255 using a content provider 255 pieces of me 256 getting a handle 257 the database-style api 257 the file system-style api 262 building content providers 262 first some dissection 263 next some typing 264 implementing the database-style api 265 implementing the file system-style api 269 issues with content providers 270 content provider implementation patterns 273 the single-table database-backed content provider 273 step #1 create a provider class 273 step #2 supply a uri 280 step #3 declare the columns 281 ix
[close]
p. 11
step #4 update the manifest 282 the local-file content provider 282 step #1 create the provider class 282 step #2 update the manifest 285 using this provider 286 the contacts content provider 287 introducing you to your contacts 287 contentprovider recap 288 organizational structure 288 a look back at android 1.6 289 pick a peck of pickled people 289 spin through your contacts 293 contact permissions 294 pre-joined data 294 the sample activity 295 dealing with api versions 297 accessing people 300 accessing phone numbers 302 accessing email addresses 302 makin contacts 303 searching with searchmanager 309 hunting season 309 search yourself 311 craft the search activity 312 update the manifest 315 searching for meaning in randomness 317 may i make a suggestion 319 x
[close]
p. 12
searchrecentsuggestionsprovider 320 custom suggestion providers 322 integrating suggestion providers 323 putting yourself almost on par with google 324 implement a suggestions provider 325 augment the metadata 325 convince the user 326 the results 327 introspection and integration 331 would you like to see the menu 332 give users a choice 334 asking around 335 middle management 339 finding applications and packages 339 finding resources 340 finding components 340 get in the loop 341 the manifest 342 the main activity 343 the test activity 344 the results 345 take the shortcut 346 registering a shortcut provider 347 implementing a shortcut provider 347 using the shortcuts 349 your own private url 353 manifest modifications 353 xi
[close]
p. 13
creating a custom url 355 reacting to the link 356 homing beacons for intents 358 working with sms 359 sending out an sos give or take a letter 359 sending via the sms client 360 sending sms directly 360 inside the sender sample 361 you can t get there from here 367 receiving sms 367 working with existing messages 369 more on the manifest 371 just looking for some elbow room 371 configuring your app to reside on external storage 372 what the user sees 374 what the pirate sees 376 what your app sees when the card is removed 377 choosing whether to support external storage 380 using an alias 381 device configuration 383 the happy shiny way 384 settings.system 384 wifimanager 384 the dark arts 385 settings.secure 385 system properties 386 automation both shiny and dark 387 xii
[close]
p. 14
push notifications with c2dm 389 pieces of push 390 the account 390 the android app 390 your server 390 google s server 391 google s on-device code 391 google s client code 391 getting from here to there 391 permissions for push 392 registering an interest 393 push it real good 397 getting authenticated 397 sending a notification 398 about the message 399 a controlled push 399 message parameters 400 notable message responses 401 the right way to push 401 the role of scripting languages 405 all grown up 405 following the script 406 your expertise 406 your users expertise 407 crowd-developing 407 going off-script 408 security 408 xiii
[close]
p. 15
performance 409 cross-platform compatibility 409 maturity on android 410 the scripting layer for android 411 the role of sl4a 411 on-device development 411 getting started with sl4a 412 installing sl4a 412 installing interpreters 412 running supplied scripts 417 writing sl4a scripts 420 editing options 420 calling into android 423 browsing the api 424 running sl4a scripts 425 background 426 shortcuts 426 other alternatives 427 potential issues 427 security from scripts 427 security from other apps 428 jvm scripting languages 429 languages on languages 429 a brief history of jvm scripting 430 limitations 431 android sdk limits 431 wrong bytecode 432 xiv
[close]