Replace intents for notification within app

By : Manjari
Source: Stackoverflow.com
Question!

Intents are taking too long to be process in my app. Is there a better way I can tell different elements of my app that something has happened? For example I use:

Intent i = new Intent("com.ftx.player_died");

I listen for that intent on two different places in my app. I would not like to make the same call twice.

Inventory.playerDied(true);
NotificationBar.playerDied(true);

Doesn't scale nicely.

Is there something I can use that is faster than intents but that I don't make same call twice or three times?

By : Manjari


Answers

It depends on a lot of factors. It is needed to see of your project to give a piece of advice. But in some cases it is possible to use usual interface that declared and shared in the static Application class.



Using LocalBroadcastManager orEventBus is not only faster the normal BroadcastManager, but also is private to your app (that means other application cant listen to your Intent action)



This video can help you solving your question :)
By: admin