0

I'm having trouble working with async callbacks in Java/Android.

Currently, the object that handles my network calls looks like this:

class Reciever {
    ...
    public String getData(String params) {
        ...
        networkLibrary.runInBackground(String url, new networkCallback() {
            public void done(String data, Exception e) { 
                // do something 
            };
        };

What I'd like to be able to do is, in another object, make a call like:

data = reciever.getData();
doSomethingWith(data);

Is there a different strategy I should be trying here?

chowes
  • 11

1 Answers1

0

You should look into a Future implementation in your async and callback methods.

EDIT: For a concrete implementation, look into FutureTasks

Brandon
  • 284
  • 2
  • 7