How to manage what broadcasts Broadcast Receivers receive in Kotlin

Oscar de la Hera Gomez
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.

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.

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.
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