What is the use of android:exported="true" in BroadcastReceiver

AndroidBroadcastreceiver

Android Problem Overview


Hi I see that some broadcast receiver use this tag android:exported="true" in Android Manifest.xml to register.

<receiver android:exported="true" android:name="com.flyingsoftgames.googleplayquery.QueryReceiver">
    <intent-filter>
       <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

What exactly the use of android:exported="true" to register broadcast receiver in Android ?

Thanks in advance.

Android Solutions


Solution 1 - Android

From the Developer Guide:

> android:exported Whether or not the broadcast receiver can receive messages from sources outside its application — "true" if it can, and "false" if not. If "false", the only messages the broadcast receiver can receive are those sent by components of the same application or applications with the same user ID. The default value depends on whether the broadcast receiver contains intent filters. The absence of any filters means that it can be invoked only by Intent objects that specify its exact class name. This implies that the receiver is intended only for application-internal use (since others would not normally know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the broadcast receiver is intended to receive intents broadcast by the system or other applications, so the default value is "true".

>This attribute is not the only way to limit a broadcast receiver's external exposure. You can also use a permission to limit the external entities that can send it messages (see the permission attribute).

Solution 2 - Android

android:exported

true : broadcast receiver can receive events sent by same or others applications

false‍ : broadcast receiver can receive events sent by same application

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionN SharmaView Question on Stackoverflow
Solution 1 - AndroidMouView Answer on Stackoverflow
Solution 2 - AndroidHaresh ChhelanaView Answer on Stackoverflow