In order to receive the notifications, we have to install an Android companion app on our smartphone. Just to simplify the system, this Android app will:
- Subscribe to the channel used by the Android Things app to send notifications.
- Implement a service to listen to the incoming notification.
- Show the notification to the user.
If you do not know how to receive notifications in Android you can visit https://firebase.google.com/docs/android/setup to know more. The source code of the Android companion app is provided with this book's source code. The app interface is very simple because we simply have to subscribe to the topic and wait for the incoming notifications.
To install the app, just open the project using Android Studio and connect your smartphone to your PC/Mac. Add the
google-services.json file to your app module. This file is the same one that you downloaded in the previous steps. Run and install the app on your smartphone. That's all.
The following screenshot shows...