文件名称:
Beginning.Android.2.(Apress,.2010,.1430226293).pdf
开发工具:
文件大小: 10mb
下载次数: 0
上传时间: 2011-09-14
详细说明: Beginning.Android.2.(Apress,.2010,.1430226293).pdf 很好的一本英文资料,417页.书名: Begin the journey toward your own successful Android 2 applications Beginning.Android.2. Contents at a Glance Contents at a Glance .............................. iv Contents.........v About the Author.................................. xiii Acknowledgments ................................xiv Preface...................................................xv Chapter 1: The Big Picture ....................... 1 Chapter 2: Projects and Targets ........ ...... 5 Chapter 3: Creating a Skeleton Application ....................................................17 Chapter 4: Using XML-Based Layouts.... 23 Chapter 5: Employing Basic Widgets ..... 29 Chapter 6: Working with Containers...... 39 Chapter 7: Using Selection Widgets....... 59 Chapter 8: Getting Fancy with Lists....... 75 Chapter 9: Employing Fancy Widgets and Containers ....................................95 Chapter 10: The Input Method Framework ...................................................117 Chapter 11: Applying Menus................ 125 Chapter 12: Fonts................................ 137 Chapter 13: Embedding the WebKit Browser................................................141 Chapter 14: Showing Pop-Up Messages.......................................................149 Chapter 15: Dealing with Threads ....... 155 Chapter 16: Handling Activity Life Cycle Events ...........................................167 Chapter 17: Creating Intent Filters ...... 171 Chapter 18: Launching Activities and Subactivities .....................................177 Chapter 19: Handling Rotation............. 185 Chapter 20: Working with Resources .. 197 Chapter 21: Using Preferences ............ 213 Chapter 22: Managing and Accessing Local Databases ...............................225 Chapter 23: Accessing Files................. 237 Chapter 24: Leveraging Java Libraries 245 Chapter 25: Communicating via the Internet................................................253 Chapter 26: Using a Content Provider.. 259 Chapter 27: Building a Content Provider ......................................................265 Chapter 28: Requesting and Requiring Permissions ....................................275 Chapter 29: Creating a Service ............ 279 Chapter 30: Invoking a Service............ 285 Chapter 31: Alerting Users via Notifications.................................................289 Chapter 32: Accessing Location-Based Services..........................................295 Chapter 33: Mapping with MapView and MapActivity..................................301 Chapter 34: Handling Telephone Calls . 311 Chapter 35: Development Tools ........... 315 Chapter 36: Handling Multiple Screen Sizes.................................................331 Chapter 37: Dealing with Devices........ 353 Chapter 38: Handling Platform Changes.......................................................359 Chapter 39: Where Do We Go from Here? .....................................................367 Index ..........369 v Contents Contents at a Glance..........................iv Contents ........ v About the Author ..................................xiii Acknowledgments..........................................................................xiv Preface .........xv Chapter 1: The Big Picture............................1 Challenges of Smartphone Programming .............1 What Androids Are Made Of.................................2 Stuff at Your Disposal ..........................................3 Chapter 2: Projects and Targets.................5 Pieces and Parts ..................................................5 Creating a Project ................................................6 Project Structure..................................................6 Root Contents .................................................6 The Sweat Off Your Brow................................7 And Now, the Rest of the Story........................7 What You Get Out of It.....................................8 Inside the Manifest ..............................................8 In the Beginning, There Was the Root, And It Was Good ......................................9 Permissions, Instrumentations, and Applications (Oh My!) .................................9 Your Application Does Something, Right? .....10 Achieving the Minimum ................................11 Version=Control ............................................12 Emulators and Targets.......................................12 Virtually There...............................................12 Aiming at a Target ........................................14 CONTENTS vi Chapter 3: Creating a Skeleton Application..........17 Begin at the Beginning.......................................17 Dissecting the Activity .......................................18 Building and Running the Activity......................20 Chapter 4: Using XML-Based Layouts ..................23 What Is an XML-Based Layout? ..........................23 Why Use XML-Based Layouts? ...........................24 OK, So What Does It Look Like?.........................24 What’s with the @ Signs?..................................25 And How Do We Attach These to the Java?........25 The Rest of the Story .........................................26 Chapter 5: Employing Basic Widgets....................29 Assigning Labels................................................29 Button, Button, Who’s Got the Button? ...............30 Fleeting Images .................................................31 Fields of Green. Or Other Colors. ........................32 Just Another Box to Check.................................33 Turn the Radio Up ..............................................35 It’s Quite a View .................................................37 Useful Properties ..........................................37 Useful Methods .............................................38 Colors............................................................38 Chapter 6: Working with Containers ....................39 Thinking Linearly ...............................................39 LinearLayout Concepts and Properties ..........40 LinearLayout Example...................................42 All Things Are Relative .......................................46 RelativeLayout Concepts and Properties .......47 RelativeLayout Example................................49 Tabula Rasa .......................................................51 TableLayout Concepts and Properties ...........52 TableLayout Example....................................53 Scrollwork..........................................................54 Chapter 7: Using Selection Widgets .....................59 Adapting to the Circumstances..........................59 Lists of Naughty and Nice ..................................60 Spin Control .......................................................63 Grid Your Lions (or Something Like That...) ........66 Fields: Now with 35% Less Typing! ....................69 Galleries, Give or Take the Art ............................72 Chapter 8: Getting Fancy with Lists .....................75 Getting to First Base ..........................................75 A Dynamic Presentation.....................................77 Better. Stronger. Faster. ....................................80 Using convertView ........................................80 Using the Holder Pattern...............................81 CONTENTS vii Making a List... ..................................................84 ...And Checking It Twice ....................................89 Adapting Other Adapters....................................94 Chapter 9: Employing Fancy Widgets and Containers................................... 95 Pick and Choose ................................................95 Time Keeps Flowing Like a River........................99 Making Progress..............................................101 Seeking Resolution ..........................................101 Put It on My Tab ...............................................102 The Pieces ..................................................103 The Idiosyncrasies ......................................103 Wiring It Together .......................................104 Adding Them Up..........................................106 Intents and Views .......................................109 Flipping Them Off.............................................109 Manual Flipping ..........................................110 Adding Contents on the Fly ..........................112 Automatic Flipping......................................113 Getting in Someone’s Drawer ...........................114 Other Good Stuff ..............................................116 Chapter 10: The Input Method Framework.........117 Keyboards, Hard and Soft ................................117 Tailored to Your Needs.....................................118 Tell Android Where It Can Go ............................121 Fitting In...........................................................123 Unleash Your Inner Dvorak ..............................124 Chapter 11: Applying Menus ................125 Menus of Options.............................................125 Creating an Options Menu ...........................125 Adding Menu Choices and Submenus .........126 Menus in Context .............................................127 Taking a Peek ..................................................128 Yet More Inflation.............................................133 Menu XML Structure ...................................133 Menu Options and XML...............................134 Inflating the Menu.......................................135 Chapter 12: Fonts ..............................137 Love the One You’re With.................................137 More Fonts.......................................................138 Here a Glyph, There a Glyph .............................140 Chapter 13: Embedding the WebKit Browser .....141 A Browser, Writ Small......................................141 Loading It Up....................................................143 Navigating the Waters......................................144 Entertaining the Client .....................................145 Settings, Preferences, and Options (Oh My!) ....147 CONTENTS viii Chapter 14: Showing Pop-Up Messages.............149 Raising Toasts..................................................149 Alert! Alert!.......................................................150 Checking Them Out..........................................151 Chapter 15: Dealing with Threads ..............155 Getting Through the Handlers ...........................155 Messages....................................................156 Runnables ...................................................158 Running in Place ..............................................159 Where Oh Where Has My UI Thread Gone?.......159 Asyncing Feeling..............................................159 The Theory ..................................................159 AsyncTask, Generics, and Varargs...............160 The Stages of AsyncTask............................160 A Sample Task ............................................161 And Now, the Caveats......................................164 Chapter 16: Handling Activity Life Cycle Events.167 Schroedinger’s Activity ....................................167 Life, Death, and Your Activity...........................168 onCreate() and onDestroy() ..........................168 onStart(), onRestart(), and onStop() .............169 onPause() and onResume() ..........................169 The Grace of State ...........................................169 Chapter 17: Creating Intent Filters ..............171 What’s Your Intent?..........................................171 Pieces of Intents .........................................172 Intent Routing .............................................172 Stating Your Intent(ions) ..................................173 Narrow Receivers ............................................174 The Pause Caveat ............................................175 Chapter 18: Launching Activities and Subactivities.................................... 177 Peers and Subs................................................177 Start ’Em Up.....................................................178 Make an Intent............................................178 Make the Call ..............................................178 Tabbed Browsing, Sort Of ................................182 Chapter 19: Handling Rotation ......................185 A Philosophy of Destruction.............................185 It’s All the Same, Just Different ........................185 Now with More Savings!..................................189 DIY Rotation .....................................................191 Forcing the Issue .............................................193 Making Sense of It All ......................................195 Chapter 20: Working with Resources.................197 The Resource Lineup .......................................197 String Theory ...................................................198 CONTENTS ix Plain Strings................................................198 String Formats ............................................198 Styled Text ..................................................199 Styled String Formats .................................199 Got the Picture? ...............................................202 XML: The Resource Way ..................................204 Miscellaneous Values ......................................206 Dimensions .................................................207 Colors..........................................................207 Arrays..........................................................208 Different Strokes for Different Folks .................208 Chapter 21: Using Preferences.....................213 Getting What You Want ....................................213 Stating Your Preference...................................214 And Now, a Word from Our Framework............214 Letting Users Have Their Say...........................215 Adding a Wee Bit o' Structure..........................219 The Kind of Pop-Ups You Like..........................221 Chapter 22: Managing and Accessing Local Databases.............................. 225 The Database Example ....................................225 A Quick SQLite Primer......................................227 Start at the Beginning......................................227 Setting the Table..............................................230 Makin’ Data......................................................230 What Goes Around Comes Around ....................232 Raw Queries................................................232 Regular Queries ..........................................232 Building with Builders.................................233 Using Cursors..............................................234 Data, Data, Everywhere ...................................235 Chapter 23: Accessing Files .....................237 You and the Horse You Rode in On ...................237 Readin’ ’n Writin’ .............................................240 Chapter 24: Leveraging Java Libraries ...........245 The Outer Limits...............................................245 Ants and JARs..................................................246 Following the Script.........................................246 ...And Not a Drop to Drink ................................250 Reviewing the Script........................................251 Chapter 25: Communicating via the Internet .....253 REST and Relaxation........................................253 HTTP Operations via Apache HttpClient ............254 Parsing Responses ..........................................255 Stuff to Consider ..............................................257 Chapter 26: Using a Content Provider .............259 Pieces of Me ....................................................259 CONTENTS x Getting a Handle ..............................................260 Makin’ Queries.................................................260 Adapting to the Circumstances........................261 Give and Take ..................................................263 Beware of the BLOB!........................................264 Chapter 27: Building a Content Provider ..........265 First, Some Dissection .....................................265 Next, Some Typing...........................................266 Creating Your Content Provider........................267 Step 1: Create a Provider Class ...................267 Step 2: Supply a Uri ....................................272 Step 3: Declare the Properties .....................272 Step 4: Update the Manifest ........................273 Notify-on-Change Support ...............................273 Chapter 28: Requesting and Requiring Permissions ................................... 275 Mother, May I?.................................................275 Halt! Who Goes There? ....................................276 Enforcing Permissions via the Manifest.......277 Enforcing Permissions Elsewhere ...............278 May I See Your Documents?............................278 Chapter 29: Creating a Service....................279 Service with Class ...........................................279 There Can Only Be One ....................................280 Manifest Destiny ..............................................281 Lobbing One Over the Fence............................282 Callbacks ....................................................283 Broadcast Intents........................................283 Where’s the Remote? And the Rest of the Code? ...............................................284 Chapter 30: Invoking a Service ...................285 The Ties That Bind ...........................................286 Catching the Lob..............................................287 Chapter 31: Alerting Users via Notifications .....289 Types of Pestering ...........................................289 Hardware Notifications ...............................290 Icons ...........................................................290 Seeing Pestering in Action...............................290 Chapter 32: Accessing Location-Based Services ........................................ 295 Location Providers: They Know Where You’re Hiding .........................................295 Finding Yourself ...............................................296 On the Move.....................................................297 Are We There Yet? Are We There Yet? Are We There Yet? .......................................298 Testing...Testing... ...........................................299 Chapter 33: Mapping with MapView and MapActivity ................................ 301 Terms, Not of Endearment...............................301 Piling On...........................................................302 The Bare Bones................................................302 CONTENTS xi Exercising Your Control....................................303 Zoom...........................................................304 Center .........................................................304 Rugged Terrain ................................................304 Layers upon Layers..........................................305 Overlay Classes...........................................305 Drawing the ItemizedOverlay......................305 Handling Screen Taps.................................307 My, Myself, and MyLocationOverlay .................307 The Key to It All ..........................308 Chapter 34: Handling Telephone Calls..............311 Report to the Manager ..............................311 You Make the Call!..............................312 Chapter 35: Development Tools.....................315 Hierarchical Management................................315 Delightful Dalvik Debugging Detailed, Demoed 321 Logging ...........................................322 File Push and Pull .................................323 Screenshots ...................................324 Location Updates ..............................325 Placing Calls and Messages ........................326 Put It on My Card ................................328 Creating a Card Image ................................328 Inserting the Card ...............................329 Chapter 36: Handling Multiple Screen Sizes ......331 Taking the Default............................................331 Whole in One.....................................332 Think About Rules, Rather Than Positions ...332 Consider Physical Dimensions....................333 Avoid Real Pixels...............................333 Choose Scalable Drawables ........................334 Tailor-Made, Just for You (and You, and You, and...).........................................334 Add ............................334 Resources and Resource Sets .....................335 Finding Your Size ..................................336 Ain’t Nothing Like the Real Thing......................337 Density Differs ............................................337 Adjusting the Density..................................337 Accessing Actual Devices ............................338 Ruthlessly Exploiting the Situation ...................339 Replace Menus with Buttons .......................339 Replace Tabs with a Simple Activity............340 Consolidate Multiple Activities....................340 Example: EU4You .............................340 The First Cut..............................340 Fixing the Fonts .............................346 Fixing the Icons..................................348 CONTENTS xii Using the Space..............348 What If It’s Not a Browser? ......................350 What Are a Few Bugs Among Friends?.............351 Chapter 37: Dealing with Devices.................353 This App Contains Explicit Instructions.............353 Button, Button, Who’s Got the Button? .............354 A Guaranteed Market ..............................355 The Down and Dirty Details ...................355 Archos 5 Android Internet Tablet .................355 Motorola CLIQ/DEXT....................................356 Motorola DROID/Milestone..........................356 Google/HTC Nexus One ...............................357 Motorola BACKFLIP .....................................357 Chapter 38: Handling Platform Changes ...........359 Brand Management .........................................359 More Things That Make You Go Boom..............360 View Hierarchy.......................360 Changing Resources ...............................361 Handling API Changes......................................362 Detecting the Version..................................362 Wrapping the API ............................362 Chapter 39: Where Do We Go from Here? ...........367 Questions—Sometimes with Answers .............367 Heading to the Source ..............................368 Getting Your News Fix......................................368 Index.......... 369 ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.