How to create an Android Notification Coordinator in Kotlin

Oscar de la Hera Gomez
Three flowers that represent Kotlin, Android and Android Studio side by side. Beneath them sits the text “Notification Coordinator.”

A step by step guide on creating a manager that can send intents from any activity or composable which can be received across an Android app.

This post is the first part of a mini series on sending and receiving functional intents in an Android app. The rest of the tutorials are available at the end.

Please note that we have chosen to use the term "Notifications" to standardize naming conventions across iOS and Android. If you wish to exchange Notifications for Intents, we welcome you to.

Step One: Create the Package

A screenshot of Android Studio showing how to create a package. Selected is the Coordinators package and highlighted is New > Package within the pop up that appears when you right click.

In the project, create a package called notificationCoordinator.

We recommend that you place it under coordinators.

A screenshot of Android Studio showing us naming the package notificationCoordinator.

Step Two: Create declaration file

A screenshot of Android Studio showing the NotificationCoordinator.kt file. Code available below.

In the package created in Step One, create a new Kotlin file called NotificationCoordinator.kt and paste in the code below.

Step Three: Create the Internal Intents Extension

A screenshot of Android Studio showing an empty NotificationsCoordinator+InternalIntents.kt file.

In the package created in Step One, create a new Kotlin file called NotificationCoordinator+InternalIntents.kt and leave it blank for now.

This is where you will add functionality to standardize how you send intents within your application that are only available to your application.

Step Four: Create the External Intents Extension

A screenshot of Android Studio showing an empty NotificationsCoordinator+ExternalIntents.kt file.

In the package created in Step One, create a new Kotlin file called NotificationCoordinator+ExternalIntents.kt and leave it blank for now.

This is where you will add functionality to standardize how you send intents within your application that are available outside of your application.

Step Five: Initialize

A screenshot of Android Studio showing the MainActivity.kt file, initializing the NotificationCoordinator.

The coordinator requires the base context to be able to provide receivable notifications to an app.

Initialize the NotificationCoordinator in your MainActivity.kt using the function below.

We recommend that you do this in a function called setupCoordinators() which is initialized onCreate.

NotificationCoordinator.shared.initialize(context = baseContext)

Looking to learn more about Intents in Android ?

Consult the tutorials linked below to learn more about sending and receiving Intents in Android and Kotlin.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details