android publish/subscribe pattern

pdiddy picture pdiddy · Dec 2, 2011 · Viewed 9.5k times · Source

Is there a publish/subscribe pattern in android?

What I want to achieve is I have this class that can notify interested party of an event. Then the interested party can do whatever it needs.

Coming from a .net microsoft world, this sort of thing are build in.

Do android have something similar, or I have to write some thing like an observer pattern?

Answer

ApriOri picture ApriOri · Apr 29, 2013

I found LocalBroadcastManager the most suitable for in app pub-sub style. You can always use observers but this one makes life more easy:

https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager.html

EDIT: It seems like there are couple of solutions nowdays. They surely worth mentioning: