Traveling Foreground notification

For devices running below Android 13, Google requires using a Foreground notification to alert users of background activity as established in Tuning your app's location behavior . Note that the traveling notification is only shown when the device is "traveling", that is, making a significant location change.

Android traveling Foreground notification displayed on an Android device.

  1. Add default settings
    Add default settings to your AndroidManifest.xml. Since the Sense360 SDK can start without your app calling Sense360.start() (such as on device reboot), you must add the default settings you want to start with. You may alter these at runtime by implementing the optional configuration described in Traveling Foreground notification customizations.
    <!-- Whether to enable/disable the foreground service by default -->
    <meta-data  
      android:name="com.sense360.default_enable_foreground_service"  
      android:value="true" />
    <!-- The default title of the notification -->
    <meta-data  
      android:name="com.sense360.default_foreground_service_notification_title"
      android:value="Searching for surveys..." />
    <!-- The default text of the notification -->
    <meta-data  
      android:name="com.sense360.default_foreground_service_notification_message"  
      android:value="Searching for location based surveys..." />
    <!-- Whether clicking on the notification opens the application by default -->
    <meta-data  
      android:name="com.sense360.foreground_notification_click_opens_app"  
      android:value="false" />
    <!-- Specify the Notification icon to be displayed when traveling. As of Android Oreo, the Notification icon needs to be generated by the Android Asset Studio -->
    <meta-data  
      android:name="com.sense360.foreground_service_notification_icon_drawable_name"
      android:value="ic_notification_icon" />
    Important: The notification icon must be specified and needs to meet Google's requirements for material design. The base image for the notification icon generated by the Android Asset Studio (built into Android Studio) must have a transparent background and be at least 96×96 pixels. Make sure you replace the above ic_notification_icon with the literal name of your application's notification icon (do not include the @drawable/ path before the icon name). For more information, see Create a notification icon.
  2. Test the look, feel, and interaction of the Foreground service notification
    Call this method after your call to Sense360.start():
    Sense360Testing.triggerForegroundService(getApplicationContext());
    Note that there is not pop-up notification; instead, the notification appears when going to the notification drawer (by swiping down from the top of the screen). Swiping down on the notification reveals these buttons:
    • More Info — Takes the user to our privacy page.

    • Hide Notification — Navigates the user to the Location Notifications channel settings menu for the app. The Location Notifications channel is created by Sense360 and disabling itl has no impact to the app's own notification channel. Once the user disables the Location Notifications channel, he will no longer see the Sense360 traveling foreground notification. The channel remains disabled until the user navigates back to the setting menu and re-enables the Location Notifications channel for this app. Although the channel is hidden from view, the Sense360 SDK continues to be able to collect relevant data on the user.

    Warning: Remove the call to Sense360Testing.triggerForegroundService from any production build as this call is only used for integration testing.
  3. Test the traveling Foreground notification
    Make sure to:
    • Use a device running at least Android 8.
    • Move the device at least 400 meters away from its starting position for 10 minutes.
    After 10 minutes, the Sense360 SDK will show the traveling Foreground notification. When the device detects that it has stopped moving, the SDK will keep showing the foreground notification for two more minutes and then it disappears.
You have implemented the traveling foreground notification.