Android Programming Tutorials

(Romina) #1

TUTORIAL 27


Messages From The Great


Beyond


In this tutorial, we will replace the callback system we used in previous


editions of Patchy with a broadcast Intent. This allows PostMonitor to alert


applications about new status updates without there having to be an


explicit connection between them.


Step-By-Step Instructions........................................................................


First, you need to have completed the previous tutorial. If you are


beginning the tutorials here, or if you wish to not use your existing work,


you can download a ZIP file with all of the tutorial results, and you can copy


the 26-Animation edition of Patchy to use as a starting point.


Step #1: Broadcast the Intent


Sending a broadcast Intent is rather simple, particularly for an application


like PostMonitor that already collects the information to broadcast (in this


case, friend, status, and creation date).


First, we need to choose a name for the action of the broadcast Intent. We


need something that will not collide with other such names, so it is best to


use something that has our namespace in it. Similarly, we need to have


271
Free download pdf