Controlling Your Alarm

Now that you can turn your alarm on and off (as well as tell whether it is on or off), let’s add an interface to turn this thing on and off. Add another menu item to menu/fragment_photo_gallery.xml.

Listing 26.11  Adding service toggle (menu/fragment_photo_gallery.xml)

<​m​e​n​u​ ​x​m​l​n​s​:​a​n​d​r​o​i​d​=​"​h​t​t​p​:​/​/​s​c​h​e​m​a​s​.​a​n​d​r​o​i​d​.​c​o​m​/​a​p​k​/​r​e​s​/​a​n​d​r​o​i​d​"​ ​ ​ ​ ​ ​ ​x​m​l​n​s​:​a​p​p​=​"​h​t​t​p​:​/​/​s​c​h​e​m​a​s​.​a​n​d​r​o​i​d​.​c​o​m​/​a​p​k​/​r​e​s​-​a​u​t​o​"​>​ ​ ​ ​ ​<​i​t​e​m​ ​a​n​d​r​o​i​d​:​i​d​=​"​@​+​i​d​/​m​e​n​u​_​i​t​e​m​_​s​e​a​r​c​h​"​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​.​.​.​ ​/​>​ ​ ​ ​ ​<​i​t​e​m​ ​a​n​d​r​o​i​d​:​i​d​=​"​@​+​i​d​/​m​e​n​u​_​i​t​e​m​_​c​l​e​a​r​"​ ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.