Can default value for exported attr for BroadcastReceiver declared in manifest be overridden

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Jul 20, 2016 10:47:59 AM via Website

If a BroadcastReceiver is declared in AndroidManifest.xml with intent-filter specified, for example

            <action android:name="android.location.PROVIDERS_CHANGED" />
            <category android:name="android.intent.category.DEFAULT" />

According to

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

I understand that if the action name is defined as custom one for intent-filter, we should specify exportedas falseas it is trueby default.

But in the above case, the action name tells that it is intended to be called from android OS and hence it doesn't give any warning even if exported flag is not specified (by default it's true)

Specifying the value for exportedin this case as falsedoes not make any difference and the app still gets the broadcast from OS.

According to the docs:

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.

My assumption is that broadcast sent by android system is a source that is outside the application. What is exactly happening here?

  • Is the default value for exportedin this case not overridden by the value explicitly specified?
  • Does application still get broadcasts from Android System even if the receiver is not exported? (and only restrict other apps to send broadcasts)