Showing Notifications at Regular Intervals

In the application you want to check the time passed to notify the user at regular intervals just as you did with the vibrate function. Here’s how.

1. Open the TimerActivity.java file in the Activity package. In the run method of the UpdateTimer class, modify the code:

if (timer.isRunning() && settings.isVibrateOn(activity)) {    vibrateCheck();}

Replace it with the code shown in Listing 5.25.

Listing 5.25 The Modified if Statement

if (timer.isRunning()) {    if (settings.isVibrateOn(activity)) {        vibrateCheck();    }    notifyCheck();}

Run Quick fix to add the missing notifyCheck method.

2. Open the strings.xml resource file, and add ...

Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications 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.