mco
mco

Reputation: 1839

Android: Can changing the BroadcastReceiver attributes in manifest prevent it from receiving broadcasts when users update an app?

Originally in my app I had this receiver set up in the manifest:

<receiver android:name = ".BootReceiver" 
    android:exported = "false">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>

However, in the new update I removed the attribute android:exported = "false" and judging from analytics there was a big dip in BootReceiver calls. Can altering the attributes in the updated app cause the BootReceiver not to be fired anymore?

Upvotes: 2

Views: 116

Answers (3)

Koustuv Ganguly
Koustuv Ganguly

Reputation: 899

From doc :

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

Means if you remove the attribute then as you are having intent filter hence by default it will be true.

Upvotes: 0

Sagar
Sagar

Reputation: 24907

android:exported = "false" indicates, the only messages the broadcast receiver can receive are those sent by components of the same application or applications with the same user ID.

OS won't be able to trigger your BootReceiver if you set exported to false. As a consequence its not fired.

Note:

If there is at least one filter, it implies that the broadcast receiver is intended to receive intents broadcast by the system or other applications, so the default value is "true".

Avoid android:exported = "false" to continue receiving the Broadcast

Upvotes: 1

Koustuv Ganguly
Koustuv Ganguly

Reputation: 899

No,it will fire.Only the external apps can not trigger that broadcast to manipulate your app.Hence,it will work as it was.Thanks!

Upvotes: 1

Related Questions