CHAPTER 5 ■ IOT PATTERNS: REALTIME CLIENTS
Screen Logic
Next you are going to add logic to the screen that will make it dynamic and create a
notification when a new message is received from the sensor.
Open the MainActivity.java file from the App ➤ Java ➤ com.codifythings.
intrusiondetectionsystem package. By default, there will be three methods auto-
generated by Android Studio, as shown in Listing 5-14.
Listing 5-14. Default Code for MainActivity.java
public class MainActivity extends AppCompatActivity {
{
@Override
protected void onCreate(Bundle savedInstanceState) { ... }
@Override
public boolean onCreateOptionsMenu(Menu menu) { ... }
@Override
public boolean onOptionsItemSelected(MenuItem item) { ... }
}
Figure 5-14. Final screen layout of app