Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

What is an implicit broadcast receiver in Andriod?

I am migrating my application from 24 to 26 (Oreo). Android has introduced certain battery optimizations for apps targeting 26. One of them is regarding implicit broadcast receivers. From the documentation,

"As part of the Android 8.0 (API level 26) Background Execution Limits, apps that target the API level 26 or higher can no longer register broadcast receivers for implicit broadcasts in their manifest. However, several broadcasts are currently exempted from these limitations. Apps can continue to register listeners for the following broadcasts, no matter what API level the apps target."

Source: https://developer.android.com/guide/components/broadcast-exceptions

Could you please explain what exactly is an implicit broadcast receiver? I see examples with System sent broadcasts and I am clear on that. Receivers that are registered in the manifest file with a custom string(prefixed with fully classified path) as the intent action and having a name that points to a class within the source code of the application - do they qualify as implicit or explicit broadcasts?

Example:

<receiver
android:name="com.app.customBroadcastReceiverClass"
android:exported="false">
<intent-filter android:priority="0">
<action android:name="com.app.CUSTOM_STRING"/>
</intent-filter>
</receiver>

Are such receivers implicit or explicit?

1 Answer

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

Hello! An implicit broadcast would be one that doesn't target a specific app. I believe in your case what you've got would be an explicit broadcast.

It might help to think about implicit vs explicit Intents. When you click to share something as an email, instead of launching straight into the email app (explicit Intent), it shows you a list of apps that can handle email and you pick which one to use (implicit Intent).