androidbroadcastreceiversticky-broadcast

How to replace sendStickyBroadcast in Android?


As you know, sendStickyBroadcast method is now deprecated. How to replace it?

Of course I can use sendBroadcast but then it will be not sticky.


Solution

  • You could use an event bus, the following are some of the most used libraries. - https://github.com/greenrobot/EventBus - http://square.github.io/otto/ - https://blog.kaush.co/2014/12/24/implementing-an-event-bus-with-rxjava-rxbus/ (how to use Rx as an event bus)

    Another approach would be to create a class that listens to the broadcast and then stores the last state that it retrieved. In my opinion, this approach would not be ideal though.