Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 288
N Sharma Avatar asked Dec 13 '14 11:12

N Sharma


1 Answers

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

like image 134
Mou Avatar answered Oct 17 '22 03:10

Mou