How to manage what broadcasts Broadcast Receivers receive in Kotlin

A guide that explains how to allow Android broadcast receivers to listen to or ignore broadcasts from other apps.

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 06/15/2023 at 11:09
Last Updated on 06/15/2023 at 12:54
Three flowers that represent Kotlin, Android and Android Studio side by side. Beneath them sits the text “Security | Broadcast Recievers.”

A guide that explains how to allow Android broadcast receivers to listen to or ignore broadcasts from other apps.

SubscribeDownload Open Source Kotlin Starter Project
A screenshot from Google I/O 2023 showing how to listen to broadcasts from other apps as well as how not to. This is available below as well as the link to the talk.

Approximately 17.35 minutes in.

As discussed at Google I/O 2023, registering receivers with intention using the RECEIVER_EXPORTED / RECEIVER_NOT_EXPORTED flag was introduced as part of Android 13 and is now a requirement for apps running on Android 14 or higher (U+).

If you do not implement this, the system will throw a security exception.

Google I/O 2023: What's new in Android privacy and security

I want the receiver to listens to broadcasts from other apps

To allow the broadcast receiver to receive broadcasts from other apps, register the receiver using the following code:

context.registerReceiver (broadcastReceiver, intentFilter, RECEIVER_EXPORTED);

I do not want the receiver to listens to broadcasts from other apps

To register a broadcast receiver that does not receive broadcasts from other apps, including system apps, register the receiver using the following code:

context.registerReceiver (broadcastReceiver, intentFilter, RECEIVER_NOT_EXPORTED);

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.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe