June 2017
Intermediate to advanced
232 pages
5h 4m
English
Once you have configured the Firebase project, we can add the notification feature to the alarm system.
Copy the NotificationManager.java class shipped with this book's source code into your project under the package androidthings.project.alarm.util. This class manages the connection to the Firebase and sends the notification.
Now open MainActivity.javaand in the onGpioEdge method of the callback class add the following lines:
public boolean onGpioEdge(Gpio gpio) { try { boolean callBackState = gpio.getValue(); Log.d(TAG, "Call back state ["+callBackState+"]"); NotificationManager.getInstance() .sendNotificaton("Alarm!", server_key); } catch(IOException ioe) { ioe.printStackTrace();Read now
Unlock full access