Android Programming Tutorials

(Romina) #1
Messages From The Great Beyond

If we intend to keep support for both the callback and the broadcast Intent,


we might consider refactoring our code, such that the TimelineEntry


addition is centrally defined.


You will need to add imports for android.content.BroadcastReceiver,


android.content.Context, and android.content.IntentFilter.


At this point, recompile and reinstall Patchy. Patchy should run as it did


before, just via broadcast Intent objects instead of the callback.


Extra Credit...............................................................................................


Here are some things you can try beyond those step-by-step instructions:



  • Get rid of the callback API. Since the service tracks accounts by the


callback object (it is the key to the Map), you will need to restructure
how the service tracks those accounts, such as using the screen

name.



  • Create a separate "sniffer" project that listens for the same
    broadcast Intent. Confirm that it too receives the broadcasts from


PostMonitor.


Further Reading........................................................................................


The use of Intent filters for broadcast Intent objects is covered briefly in the


"Creating Intent Filters" chapter of The Busy Coder's Guide to Android


Development.


274
Free download pdf