How to Test Plot Integration on Android

Previously we showed how to verify that the Plot plugin was integrated properly in an IOS app. This post shows how to verify the Android integration of the Plot plugin.

Test Receiving Notifications

Of course the most important feature of the Plot plugin is sending location based notifications. Just like in IOS, you can verify the Plot plugin is integrated properly by receiving a location based notification. The easiest way of doing that is adding a test notification at your current location. When you have received that notification, you can be sure that notifications can be received. It is advisable to create a separate account for testing purposes to prevent bothering your end users with these notifications. Creating an extra account just for testing purposes is free and can be done here.

Let’s start with creating a notification to test. You can create a notification in our dashboard. Login with the private token we have provided you. First create a place at your current position. Then add a notification and set the status of that notification to ‘published’.

Plot tries to update its database once every hour. This isn’t influenced by whether the app has been opened or closed in this period. Therefore when a new notification has been added it may take up to one hour before that notification is downloaded and may be received by the user.
For testing purposes, you can trigger a database update by clearing the local database of your app on your phone. To clear the local database you have to open the Apps section under settings and find your app. There you can stop the app and clear local data. When the app is then opened again it will directly start downloading the notifications and, when you are at the right location of course, show the notifications.

When a notification has been received, it won’t be send again. Cleaning the local database will make it possible to receive a notification again. This can make testing easier.

Enabling and Understanding Log Messages

Plot provides log messages to help you diagnose situations where no notification is shown. It for example helps you distinguishing between situations where Plot thinks it isn’t close enough to a location or whether the notification filter dropped the notification.

In Android you have to explicitly enable log messages. You can enable log messages by setting the debug flag on the Plot background service in your AndroidManifest.xml. Find the section with PlotBackgroundService in your manifest and add a meta-data entry for “debug” with the value “true”. It will look then like this:

<service android:name=""
            <meta-data android:name="debug" android:value="true" />

The messages are then sent to LogCat. Most IDEs have the possibility to show these messages directly from there.

When enabling Plot you should see the following log message:

12-02 11:01:54: DEBUG/Example/Plot(32209): Enabling Plot plugin.

After Plot is enabled, it will download the notifications from the server. This should happen once per hour. It shows the total number of notifications and the notifications that have been loaded. You can use this message to ensure the right notifications are loaded.

12-02 10:33:01: DEBUG/Example/Plot(30227): Received 25 notifications.
12-02 10:33:01: DEBUG/Example/Plot(30227): Loaded Notification{id='54ad03f48be34dcbb1a5711a1937b924', location=Location{latitude=52.1345, longitude=5.0857}, message='…', timespans=[], data='…', matchRange='200'}

Once the notifications are loaded, then Plot can match these notifications. It shows the notifications that were considered and the distance to these notifications in meters. When the distance is smaller than the match range, then a notification “matches” and will be sent to the notification filter (if you have one defined). Checking the distance for the notifications should happen at least once every 10 minutes.

12-02 11:02:06: DEBUG/Example/Plot(32209): Checking for matches.
12-02 10:33:03: DEBUG/Example/Plot(30227): Distance to 54ad03f48be34dcbb1a5711a1937b924: 25 (match range: 200)

When there are one or more notifications sent to the notification filter, then you should see the following three lines. First the number of matching notifications, followed by details about these notifications. When you don’t have a notification filter, then this step is skipped.

12-02 11:02:06: DEBUG/Example/Plot(32193): Received 1 notifications for filtering
12-02 11:02:06: DEBUG/Example/Plot(32193): FilterableNotification(id = b484b3ab7fcc41cda7635a07bb5c69a5, message = …, data = …)

When the notification filter is completed, then the following log message appears. It shows how many notifications passed through the notification filter and then shows these notifications. These notifications should then appear in the notification area.

12-02 11:02:06: DEBUG/Example/Plot(32193): 1 notifications passed
12-02 11:02:06: DEBUG/Example/Plot(32193): FilterableNotification(id = b484b3ab7fcc41cda7635a07bb5c69a5, message = …, data = …)

Wrap Up

Testing your Android integration isn’t hard. We have shown you how you can verify that your app can successfully receive notifications and what to make of the log messages Plot may print. Don’t forget to disable the debug log messages when releasing your application.

We hope that this blogpost made it clearer how to properly integrate the Plot plugin into your Android application. If you have problems during one of these steps, we have a discussion group you can post your question to. We will then help you the best we can.

Spread the love