E
E
epag2015-09-25 22:21:49
Java
epag, 2015-09-25 22:21:49

How to wait for callback to finish?

Есть код
MyTwitterSession.getInstance().setSession(result);
TwitterSession session = MyTwitterSession.getInstance().getSession();
new MyTwitterApiClient(session).getStatusesService().userTimeline(null, session.getUserName(), 10, null, null, null, null, null, null, new Callback>() {
@Override
public void success(Result> result) {;
MyTwitterSession.getInstance().setTweets(result.data);
}
@Override
public void failure(TwitterException e) {
}
});
MyTwitterSession is a singleton class. How can I wait for the callback to complete? At the time when it is necessary to use a field from a singleton class, it is null.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Gamega, 2015-09-25
@gadfi

if I understand the question correctly, then you do not understand the essence of asynchronous task execution.
No way.
It doesn't depend on you when the request is executed, you just handle the result of success/failure

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question