Building Arduino Projects for the Internet of Things

(Steven Felgate) #1
CHAPTER 6 ■ IOT PATTERNS: REMOTE CONTROL

Your app’s screen layout is ready, and it should look similar to Figure  6-14.

Figure 6-13. Dialog box for adding an image to an app


Figure 6-14. Final screen layout of app


Screen Logic


Next you are going to make the screen interactive so that app users can tap on the light
bulb icon to turn the lights on or off. This app does not display if the lights are currently
on or off; instead, it simply switches the state from on to off and from off to on.
Open the MainActivity.java file from the App ➤ Java ➤ com.codifythings.
lightingcontrolsystem package. By default, there will be three methods auto-generated
by Android Studio as shown in Listing 6-6.

Free download pdf