Asiaing.com: Free eBooks, Free Magazines, Free Magazine Subscriptions

Saturday
Nov 21st
Text size
  • Increase font size
  • Default font size
  • Decrease font size
Home arrow eBook Categories arrow Computers & Internet arrow The Busy Coder's Guide to Android Development

The Busy Coder's Guide to Android Development

Monday, 02 February 2009

The Busy Coder's Guide to Android DevelopmentAndroid, the next-generation open mobile platform from Google and the Open Handset Alliance, is poised to become a significant player in the mobile device market. The Android platform gives developers a fair bit of control while still supporting a familiar programming language. However, the frameworks, GUI widgets, and development model is different than any other mobile platform out there.

That's where this book comes in.

CHAPTER 1 The Big Picture
Android devices, by and large, will be mobile phones. While the Android technology is being discussed for use in other areas (e.g., car dashboard "PCs"), for the most part, you can think of Android as being used on phones.

For developers, this has benefits and drawbacks.

On the plus side, circa 2008, Android-style smartphones are sexy. Offering Internet services over mobile devices dates back to the mid-1990's and the Handheld Device Markup Language (HDML). However, only in recent years have phones capable of Internet access taken off. Now, thanks to trends like text messaging and to products like Apple's iPhone, phones that can serve as Internet access devices are rapidly gaining popularity.

So, working on Android applications gives you experience with an interesting technology (Android) in a fast-moving market segment (Internet-enabled phones), which is always a good thing.

The problem comes when you actually have to program the darn things. ...

Visit The Busy Coder's Guide to Android Development Website

The Busy Coder's Guide to Android Development
By Mark L. Murphy
CommonsWare, LLC.
ISBN: 978-0-9816780-0-9

Download The Busy Coder's Guide to Android Development, Sampler/Preview Edition

PDF format, 3.2MB, 120Pages.

Table of Contents
Welcome to the Warescription!............................................................xv
Preface.................................................................................................xvii
Welcome to the Book!..............................................................................xvii
Prerequisites.............................................................................................xvii
Warescription..........................................................................................xviii
Book Bug Bounty.......................................................................................xix
Source Code License...................................................................................xx
Creative Commons and the Four-to-Free (42F) Guarantee....................xx
Acknowledgments.....................................................................................xxi
The Big Picture.........................................................................................1
What Androids Are Made Of.......................................................................3
Activities.................................................................................................3
Content Providers..................................................................................4
Intents.....................................................................................................4
Services...................................................................................................4
Stuff At Your Disposal..................................................................................5
Storage.....................................................................................................5
Network...................................................................................................5
Multimedia.............................................................................................5
GPS..........................................................................................................5
Phone Services........................................................................................6
Project Structure.....................................................................................7
Root Contents...............................................................................................7
The Sweat Off Your Brow............................................................................8
And Now, The Rest of the Story..................................................................8
What You Get Out Of It..............................................................................9
Inside the Manifest................................................................................11
In The Beginning, There Was the Root, And It Was Good......................11
Permissions, Instrumentations, and Applications (Oh, My!)..................12
Your Application Does Something, Right?................................................13
Creating a Skeleton Application...........................................................17
Begin at the Beginning................................................................................17
The Activity..................................................................................................18
Dissecting the Activity................................................................................19
Building and Running the Activity............................................................21
Using XML-Based Layouts.....................................................................25
What Is an XML-Based Layout?................................................................25
Why Use XML-Based Layouts?.................................................................26
OK, So What Does It Look Like?...............................................................27
What's With the @ Signs?.........................................................................28
And We Attach These to the Java...How?................................................28
The Rest of the Story..................................................................................29
Employing Basic Widgets......................................................................33
Assigning Labels..........................................................................................33
Button, Button, Who's Got the Button?...................................................34
Fleeting Images...........................................................................................35
Fields of Green. Or Other Colors..............................................................36
Just Another Box to Check.........................................................................38
Turn the Radio Up......................................................................................41
It's Quite a View..........................................................................................43
Useful Properties..................................................................................43
Useful Methods....................................................................................44
Working with Containers......................................................................45
Thinking Linearly.......................................................................................46
Concepts and Properties.....................................................................46
Example................................................................................................49
All Things Are Relative...............................................................................54
Concepts and Properties......................................................................54
Example.................................................................................................57
Tabula Rasa.................................................................................................60
Concepts and Properties.....................................................................60
Example.................................................................................................63
Scrollwork...................................................................................................64
Using Selection Widgets.......................................................................69
Adapting to the Circumstances.................................................................69
Using ArrayAdapter.............................................................................70
Other Key Adapters..............................................................................71
Lists of Naughty and Nice..........................................................................72
Spin Control................................................................................................74
Grid Your Lions (Or Something Like That...)..........................................78
Fields: Now With 35% Less Typing!..........................................................82
Galleries, Give Or Take The Art................................................................86
Getting Fancy With Lists.......................................................................89
Getting To First Base..................................................................................89
A Dynamic Presentation............................................................................92
A Sidebar About Inflation...................................................................94
And Now, Back To Our Story.............................................................94
Better. Stronger. Faster..............................................................................95
Using convertView...............................................................................96
Using the Holder Pattern....................................................................98
Making a List..............................................................................................101
...And Checking It Twice..........................................................................107
Employing Fancy Widgets and Containers..........................................115
Pick and Choose.........................................................................................115
Time Keeps Flowing Like a River.............................................................120
Making Progress.........................................................................................121
Putting It On My Tab................................................................................122
The Pieces............................................................................................123
The Idiosyncrasies...............................................................................123
Wiring It Together..............................................................................125
Adding Them Up................................................................................128
Intents and Views................................................................................131
Flipping Them Off......................................................................................131
Other Containers of Note.........................................................................137
Applying Menus....................................................................................139
Flavors of Menu.........................................................................................139
Menus of Options.....................................................................................140
Menus in Context......................................................................................142
Taking a Peek.............................................................................................143
Yet More Inflation.....................................................................................149
Menu XML Structure..........................................................................149
Menu Options and XML.....................................................................151
Inflating the Menu..............................................................................152
Fonts......................................................................................................155
Love The One You're With.......................................................................155
Embedding the WebKit Browser.........................................................159
A Browser, Writ Small..............................................................................159
Loading It Up.............................................................................................162
Navigating the Waters..............................................................................163
Entertaining the Client.............................................................................164
Settings, Preferences, and Options (Oh, My!)........................................166
Showing Pop-Up Messages..................................................................169
Raising Toasts............................................................................................169
Alert! Alert!................................................................................................170
Checking Them Out...................................................................................171
Dealing with Threads...........................................................................175
Getting Through the Handlers.................................................................175
Messages..............................................................................................176
Runnables............................................................................................179
Running In Place.......................................................................................179
Where, Oh Where Has My UI Thread Gone?.........................................180
And Now, The Caveats.............................................................................180
Handling Activity Lifecycle Events......................................................183
Schroedinger's Activity.............................................................................183
Life, Death, and Your Activity..................................................................184
onCreate() and onDestroy()..............................................................184
onStart(), onRestart(), and onStop().................................................185
onPause() and onResume()................................................................185
The Grace of State.....................................................................................186
Using Preferences.................................................................................191
Getting What You Want...........................................................................191
Stating Your Preference............................................................................192
And Now, a Word From Our Framework...............................................193
Letting Users Have Their Say...................................................................194
Adding a Wee Bit O' Structure................................................................199
The Kind Of Pop-Ups You Like...............................................................202
Accessing Files.....................................................................................207
You And The Horse You Rode In On......................................................207
Readin' 'n Writin'.......................................................................................211
Working with Resources......................................................................217
The Resource Lineup.................................................................................217
String Theory.............................................................................................218
Plain Strings........................................................................................218
String Formats.....................................................................................219
Styled Text...........................................................................................219
Styled Formats....................................................................................220
Got the Picture?........................................................................................224
XML: The Resource Way..........................................................................227
Miscellaneous Values...............................................................................229
Dimensions.........................................................................................230
Colors..................................................................................................230
Arrays...................................................................................................231
Different Strokes for Different Folks.......................................................232
Managing and Accessing Local Databases.........................................239
A Quick SQLite Primer............................................................................240
Start at the Beginning...............................................................................241
Setting the Table.......................................................................................242
Makin' Data...............................................................................................243
What Goes Around, Comes Around.......................................................244
Raw Queries........................................................................................244
Regular Queries..................................................................................245
Building with Builders.......................................................................246
Using Cursors.....................................................................................247
Making Your Own Cursors................................................................248
Data, Data, Everywhere...........................................................................248
Leveraging Java Libraries.....................................................................251
The Outer Limits.......................................................................................251
Ants and Jars.............................................................................................252
Following the Script..................................................................................253
...And Not A Drop To Drink....................................................................258
Communicating via the Internet........................................................259
REST and Relaxation................................................................................259
HTTP Operations via Apache HttpComponents............................260
Parsing Responses..............................................................................262
Stuff To Consider...............................................................................264
Creating Intent Filters........................................................................269
What's Your Intent?.................................................................................270
Pieces of Intents.................................................................................270
Intent Routing.....................................................................................271
Stating Your Intent(ions).........................................................................272
Narrow Receivers......................................................................................274
The Pause Caveat......................................................................................275
Launching Activities and Sub-Activities.............................................277
Peers and Subs..........................................................................................278
Start 'Em Up..............................................................................................278
Make an Intent...................................................................................279
Make the Call......................................................................................279
Tabbed Browsing, Sort Of........................................................................284
Finding Available Actions via Introspection.....................................289
Pick 'Em.....................................................................................................290
Would You Like to See the Menu?.........................................................294
Asking Around..........................................................................................296
Handling Rotation...............................................................................297
A Philosophy of Destruction...................................................................297
It's All The Same, Just Different..............................................................298
Now With More Savings!.........................................................................302
DIY Rotation.............................................................................................304
Forcing the Issue.......................................................................................307
Making Sense of it All..............................................................................309
Using a Content Provider.....................................................................313
Pieces of Me................................................................................................313
Getting a Handle.......................................................................................314
Makin' Queries...........................................................................................315
Adapting to the Circumstances................................................................317
Doing It By Hand.......................................................................................318
Position................................................................................................319
Getting Properties...............................................................................319
Give and Take............................................................................................319
Beware of the BLOB!.................................................................................321
Building a Content Provider...............................................................323
First, Some Dissection..............................................................................323
Next, Some Typing...................................................................................324
Step #1: Create a Provider Class...............................................................325
onCreate()...........................................................................................325
query().................................................................................................326
insert().................................................................................................328
update()...............................................................................................329
delete()................................................................................................330
getType()..............................................................................................331
Step #2: Supply a Uri.................................................................................332
Step #3: Declare the Properties................................................................332
Step #4: Update the Manifest...................................................................333
Notify-On-Change Support.....................................................................334
Requesting and Requiring Permissions.............................................337
Mother, May I?..........................................................................................338
Halt! Who Goes There?............................................................................339
Enforcing Permissions via the Manifest...........................................340
Enforcing Permissions Elsewhere......................................................341
May I See Your Documents?.....................................................................341
Creating a Service.................................................................................343
Service with Class.....................................................................................344
When IPC Attacks!...................................................................................345
Write the AIDL...................................................................................346
Implement the Interface....................................................................347
Manifest Destiny.......................................................................................348
Lobbing One Over the Fence..................................................................349
Where's the Remote? And the Rest of the Code?..................................350
Invoking a Service................................................................................351
Bound for Success.....................................................................................352
Request for Service...................................................................................354
Prometheus Unbound..............................................................................354
Manual Transmission...............................................................................354
Catching the Lob.......................................................................................355
Alerting Users Via Notifications.........................................................359
Types of Pestering.....................................................................................359
Hardware Notifications.....................................................................360
Icons....................................................................................................360
Seeing Pestering in Action........................................................................361
Accessing Location-Based Services.....................................................367
Location Providers: They Know Where You're Hiding.........................368
Finding Yourself.......................................................................................368
On the Move.............................................................................................370
Are We There Yet? Are We There Yet? Are We There Yet?..................371
Testing...Testing........................................................................................372
Mapping with MapView and MapActivity...........................................375
Terms, Not of Endearment.......................................................................375
The Bare Bones.........................................................................................376
Exercising Your Control...........................................................................378
Zoom...................................................................................................378
Center..................................................................................................380
Rugged Terrain.........................................................................................380
Layers Upon Layers...................................................................................381
Overlay Classes....................................................................................381
Drawing the ItemizedOverlay...........................................................382
Handling Screen Taps........................................................................384
My, Myself, and MyLocationOverlay......................................................384
The Key To It All.......................................................................................385
Handling Telephone Calls...................................................................389
Report To The Manager...........................................................................390
You Make the Call!...................................................................................390
Searching with SearchManager...........................................................395
Hunting Season.........................................................................................395
Search Yourself.........................................................................................397
Craft the Search Activity...................................................................398
Update the Manifest..........................................................................402
Searching for Meaning In Randomness..................................................403
Development Tools.............................................................................407
Hierarchical Management.......................................................................407
Delightful Dalvik Debugging Detailed, Demoed...................................414
Logging................................................................................................416
File Push and Pull...............................................................................417
Screenshots.........................................................................................418
Location Updates................................................................................419
Placing Calls and Messages...............................................................420
Put It On My Card....................................................................................424
Creating a Card Image.......................................................................424
"Inserting" the Card...........................................................................425
Where Do We Go From Here?.............................................................427
Questions. Sometimes, With Answers...................................................427
Heading to the Source.............................................................................428
Getting Your News Fix.............................................................................428

Comments (0)add comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smaller | bigger

busy
 
< Prev   Next >

Subscribe

 Subscribe to the RSS feed. 

Email Subscription

Lots of FREE books & magazines delivered directly to your e-mail inbox!

Enter your email address:

eBooks, free eBooks
WebAsiaing.com