register receiver in a service

前端 未结 3 1055
青春惊慌失措
青春惊慌失措 2020-12-01 05:01

I have a service that can be started and stopped from a button.

But within the service I want to register a reciever to listen

3条回答
  •  庸人自扰
    2020-12-01 05:42

    Remove the intent-filter from the xml and do only the dynamic registration of the Receiver. If you do not want it working when the service is off, then unregister it before stopping the service. Do not forget to add the permission to the xml though....

提交回复
热议问题