Creating a callback handler to handle multiple callbacks in Android
<p>I have an Android application that interfaces 3rd party hardware through a vendor-supplied library. When data from the hardware is ready to be processed, the library calls back to my application.</p>

<p>The 3rd party library, due to it's design, only makes one callback to the application. However, my app has a few different asynchronous tasks that it would like to do when the callback is called (for example, logging, update the UI display, call external programs). Trying to fan out the event, in a way, to different methods. So, I'm thinking about doing this in my Application class:</p>

<pre><code>interface MyCallback {
    public void doSomething(ArrayList&lt;DataClass&gt;);
}

public class MyApp extends Application {
...
private MyCallback cb; 
public void registerCallback (MyCallback callback) {
    cb = callback;
}

public methodCalledBy3rdPartyAPIOnData (ArrayList&lt;DataClass&gt; data){
    cb.doSomething(ArrayList&lt;DataClass&gt; data);
}
</code></pre>

<p>which would work for a single method to call, but I'm having an issue on how to do this for a series of callbacks...and making sure they get called asynchronously. Are there any examples or best practices for doing this sort of thing in an Android application, or in Java in general?</p>
