O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 29.11  Add 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​"​>​ ​ ​<​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​"​ ​ ​ ​ ​a​n​d​r​o​i​d​:​t​i​t​l​e​=​"​@​s​t​r​i​n​g​/​s​e​a​r​c​h​"​ ​ ​ ​ ​a​n​d​r​o​i​d​:​i​c​o​n​=​"​@​a​n​d​r​o​i​d​:​d​r​a​w​a​b​l​e​/​i​c​_​m​e​n​u​_​s​e​a​r​c​h​"​ ​ ​ ​ ​a​n​d​r​o​i​d​:​s​h​o​w​A​s​A​c​t​i​o​n​=​"​i​f​R​o​o​m​"​ ​ ​ ​ ​a​n​d​r​o​i​d​:​a​c​t​i​o​n​V​i​e​w​C​l​a​s​s​=​"​a​n​d​r​o​i​d​.​w​i​d​g​e​t​.​S​e​a​r​c​h​V​i​e​w​"​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required