[英]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 要将意图发送给此接收者,我只需要使用addCategory
Answering my own question for later reference. 回答我自己的问题以供以后参考。 This is the way to add category
这是添加类别的方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.