1

I rely on broadcast send/receive for my app to work.

This code works perfectly on all platforms, but on latest Android Preview L, the broadcast is not received:

Intent intent = new Intent("com.my.BROADCAST_RECEIVED");
sendBroadcast(intent);

Receiver is registered in the manifest, as usual:

    <receiver
        android:name=".SimpleBroadcastReceiver"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.my.BROADCAST_RECEIVED" />
        </intent-filter>
    </receiver>

Note: if the receiver is registered in runtime (i.e. via registerReceiver(..)) - it does receive the broadcast.
Any information about this?

Amir Uval
  • 14,425
  • 4
  • 50
  • 74

1 Answers1

2

Found a different answer related to not receiving boot complete on SmartTv .

So as an act of despair I decided to give it a try and it worked!
Add a category tag to the intent filter. It's not documented anywhere:

<receiver
    android:name=".SimpleBroadcastReceiver"
    android:exported="false" >
    <intent-filter>
        <action android:name="com.my.BROADCAST_RECEIVED" />

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

    </intent-filter>
</receiver>

Hope this helps someone.

Community
  • 1
  • 1
Amir Uval
  • 14,425
  • 4
  • 50
  • 74