简体   繁体   English

替换意图以在应用内进行通知

[英]Replace intents for notification within app

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? 有什么我可以使用的东西比意图更快,但是我没有两次或三遍打相同的电话吗?

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. 但是在某些情况下,可以使用在静态Application类中声明和共享的常规interface

使用LocalBroadcastManagerEventBus不仅比普通的BroadcastManager更快,而且对您的应用程序是私有的(这意味着其他应用程序无法侦听您的Intent操作)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM