Axarydax
Axarydax

Reputation: 16603

Android IntentFilter performance

I'd like to refresh a specific row in a ListView (a custom class) when something happens in the ListView fragment or other (nested) fragment.

I'm currently using this pattern (News is a custom class that NewsView is displaying):

This means that each and every NewsView has to deserialize the News from the Intent and therefore this approach has a bit of an overhead.

On the other hand, I could register a broadcast receiver for each NewsView with IntentFilter like "UPDATE_NEWS_ITEM_154", where 154 is the ID of the item. Then the broadcast intent would reach only one receiver and it seems more effective.

Is there any downside to registering so many broadcast receivers? Or Android will happily cope with potentially hundred of them?

Upvotes: 1

Views: 122

Answers (1)

Greg Ennis
Greg Ennis

Reputation: 15379

If you are broadcasting only within your application, consider using intents through LocalBroadcastManager instead of broadcasting intents with an intent-filter in your manifest.

As far as I know those translate directly to function calls and do not pass through the OS queues.

More about LocalBroadcastManager here

Upvotes: 1

Related Questions