Skip to main content

Other alarms

|

The Maps SDK for Android provides advanced notification capabilities, enabling users to receive alerts for significant environmental changes. This includes notifications for entering and exiting tunnels, as well as transitions between day and night, based on the user's current location and time of year.

Get notified when entering and exiting tunnels

This snippet below demonstrates how to set up notifications for entering and exiting tunnels using the AlarmListener:

val alarmListener = AlarmListener.create {
onTunnelEntered {
Log.d("TunnelAlarm", "Tunnel entered")
// Update UI for tunnel mode (e.g., switch to night theme)
}
onTunnelLeft {
Log.d("TunnelAlarm", "Tunnel left")
// Update UI for normal mode (e.g., switch back to day theme)
}
}

Get notified when transitioning between day and night

The Maps SDK for Android offers functionality to notify users when their location transitions between day and night, based on the geographical region and the corresponding seasonal changes:

val alarmListener = AlarmListener.create {
onEnterDayMode {
Log.d("DayNightAlarm", "Day mode entered")
// Update UI for day mode (e.g., light theme)
}
onEnterNightMode {
Log.d("DayNightAlarm", "Night mode entered")
// Update UI for night mode (e.g., dark theme)
}
}