You can really use broadcasts such as NSNotification, but I usually used broadcasts to communicate between different parts of my application, for example, to communicate between the Service and Activity, and not with a specific part.
I do not understand why you cannot do what you do in iOS on Android. You will have a protocol in iOS defining which functions to call, and you can do the same in Java / Android using interfaces.
In iOS, you have something like:
doStuffWithObject:(NSObject<SpecialStuff> *)object {}
while in Java you would:
doStuffWithObject(SpecialStuff object) {}
when SpecialStuff is your protocol or interface. Since you don't have performSelectorOnBackground in android, this is a bit more. Use Timers, perhaps a separate Thread in combination with Handlers, or use ASyncTask depending on what suits you best and how large the asynchronous task is.
ASyncTask is definitely worth a look.
Of course, you can also use Observer and Observable .
A simple example with a handler and a timer that notifies its listeners of a new time every second (note that the handler is created in the main thread in this case, so you can send messages back similar to using performSelectorOnMainThread in iOS):
class SomeExample { private final ArrayList<TimeListener> timeListeners; private final Handler handler = new Handler(); private final TimeUpdateRunnable timeUpdateRunnable = new TimeUpdateRunnable(); public SomeExampleView { timeListeners = new ArrayList<TimeListener>(); updateTimer = new Timer("General Update Timer"); TimeUpdateTask timeUpdateTask = new TimeUpdateTask(); updateTimer.scheduleAtFixedRate(timeUpdateTask, (60 * 1000) - (System.currentTimeMillis() % (60 * 1000)), 60 * 1000); } public void addTimeListener(TimeListener timeListener) { timeListeners.add(timeListener); } public boolean removeTimeListener(TimeListener timeListener) { return timeListeners.remove(timeListener); } class TimeUpdateTask extends TimerTask { public void run() { handler.post(timeUpdateRunnable); } } private class TimeUpdateRunnable implements Runnable { public void run() { for (TimeListener timeListener : timeListeners) { timeListener.onTimeUpdate(System.currentTimeMillis()); } } } }
And my listener interface, which is similar to Observer
public interface TimeListener { void onTimeUpdate(long time); }