Android Programming Tutorials

(Romina) #1

TUTORIAL 20


A Subtle Notification


Right now, the only way you find out about status updates from your


friends is by looking at your application. However, perhaps there is a


certain keyword that you want to specifically watch for – perhaps your


company name. In this tutorial, we augment Patchy and PostMonitor to


watch for such a keyword, putting a Notification in the status bar when


there is a match.


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 18-LocalService edition of Patchy to use as a starting point.


Step #1: Pick a Word and Icon...........................................................


PostMonitor will watch for posts containing some word (or phrase) that you


choose...but you need to choose it. Determine what you want to watch for,


then add it as a NOTIFY_KEYWORD value in PostMonitor:


private static final String NOTIFY_KEYWORD="snicklefritz";

You will also need an icon, named status.png, in your res/drawable/


resource directory, that will be used with the Notification. You can grab


219
Free download pdf