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

Hi, I see some broadcast receiver using this android:exported="true" tag 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 is the use of android:exported="true" to register a broadcast receiver in Android?

Thanks in advance.

+15
source share
2 answers

In the Developer's Guide :

Android: exported Regardless of whether the broadcast receiver can receive messages from sources outside its application - “true” if possible, and “false” if not. If false, the only messages that 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 only be called by Intent objects that determine its exact class name. This means that the receiver is for internal use of the application only (since others usually do not know the class name). Therefore, 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 designed to receive signals broadcast by the system or other applications, therefore the default value is “true”.

This attribute is not the only way to limit the external exposure of a broadcast receiver. You can also use permission to restrict external objects that can send messages (see Permissions attribute).

+17
source

android: exported

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

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

+13
source

Source: https://habr.com/ru/post/1208943/


All Articles