Search code examples
androidandroid-intentbroadcastreceiverintentfilter

Register broadcast receiver with category


I have a broadcast receiver which works perfectly, but I am tasked with adding categories to it.

To do it in manifest is in the following way:

<intent-filter>
  <category android:name="android.intent.category.SOME_A" />
  <category android:name="android.intent.category.SOME_B" />
  <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

How do I do this programmatically? I am only able to add intent filter to it while defining it.

context.registerReceiver(myReceiver, "com.test.some_test_filter");

To send an intent to this receiver I would just use the addCategory


Solution

  • Answering my own question for later reference. This is the way to add category