Android Broadcast from Service To Activity

前端 未结 3 656
挽巷
挽巷 2020-12-16 14:00

I am trying to send a Broadcast from a service out to an Activity. I can verify the broadcast is sent from within the service, but the Activity doesn\'t pick up anything.

相关标签:
3条回答
  • 2020-12-16 14:39

    Try this two things:

    1. Use manifest file to register receiver(but it barely helps)
    2. Try make your Receiver a regular class, not inner one.
    0 讨论(0)
  • 2020-12-16 14:49

    I'm not sure if it is specific to the set up, or if it is a fix in general, but moving the register/unregister to the onResume/onPause _respectively_ and not registering in the onCreate solved the problem for me.

    0 讨论(0)
  • 2020-12-16 14:51

    Inner class broadcast receiver will not be able to handle broadcast(means it unable to locate that class ). So make it as a separate class

    Definitely it will work.

    0 讨论(0)
提交回复
热议问题