viii
33.7 Modifying the MyWebView Project Manifest File..................................................................................................................... 261
33.8 Installing the MyWebView Package on a Device ....................................................................................................................... 263
33.9 Testing the Application .............................................................................................................................................................. 264
33.10 Summary .................................................................................................................................................................................. 264
34. Android Broadcast Intents and Broadcast Receivers ..................................................................................................................... 265
34.1 An Overview of Broadcast Intents ............................................................................................................................................. 265
34.2 An Overview of Broadcast Receivers ......................................................................................................................................... 266
34.3 Obtaining Results from a Broadcast .......................................................................................................................................... 267
34.4 Sticky Broadcast Intents ............................................................................................................................................................ 267
34.5 The Broadcast Intent Example ................................................................................................................................................... 267
34.6 Creating the Example Application ............................................................................................................................................. 268
34.7 Creating and Sending the Broadcast Intent ............................................................................................................................... 268
34.8 Creating the Broadcast Receiver ............................................................................................................................................... 269
34.9 Configuring a Broadcast Receiver in the Manifest File .............................................................................................................. 270
34.10 Testing the Broadcast Example................................................................................................................................................ 271
34.11 Listening for System Broadcasts .............................................................................................................................................. 271
34.12 Summary .................................................................................................................................................................................. 272
35. A Basic Overview of Android Threads and Thread Handlers ......................................................................................................... 273
35.1 An Overview of Threads ............................................................................................................................................................ 273
35.2 The Application Main Thread .................................................................................................................................................... 273
35.3 Thread Handlers ........................................................................................................................................................................ 273
35.4 A Basic Threading Example ........................................................................................................................................................ 273
35.5 Creating a New Thread .............................................................................................................................................................. 276
35.6 Implementing a Thread Handler ................................................................................................................................................ 277
35.7 Passing a Message to the Handler ............................................................................................................................................. 278
35.8 Summary .................................................................................................................................................................................... 280
36. An Overview of Android Started and Bound Services ................................................................................................................... 281
36.1 Started Services ......................................................................................................................................................................... 281
36.2 Intent Service ............................................................................................................................................................................. 281
36.3 Bound Service ............................................................................................................................................................................ 282
36.4 The Anatomy of a Service .......................................................................................................................................................... 282
36.5 Controlling Destroyed Service Restart Options ......................................................................................................................... 283
36.6 Declaring a Service in the Manifest File ..................................................................................................................................... 283
36.7 Starting a Service Running on System Startup........................................................................................................................... 284
36.8 Summary .................................................................................................................................................................................... 284
37. Implementing an Android Started Service – A Worked Example .................................................................................................. 285
37.1 Creating the Example Project .................................................................................................................................................... 285
37.2 Creating the Service Class .......................................................................................................................................................... 285
37.3 Adding the Service to the Manifest File..................................................................................................................................... 286
37.4 Starting the Service .................................................................................................................................................................... 287
37.5 Testing the IntentService Example ............................................................................................................................................ 288
37.6 Using the Service Class .............................................................................................................................................................. 288
37.7 Creating the New Service .......................................................................................................................................................... 288
37.8 Modifying the User Interface..................................................................................................................................................... 290
37.9 Running the Application ............................................................................................................................................................ 291
37.10 Creating a New Thread for Service Tasks ................................................................................................................................ 291
37.11 Summary .................................................................................................................................................................................. 293