I am trying to fetch facebook user’s likes in android . I succeeded in fetching the likes using graph api, but could not find a way how to enable notification mechanism so that it updates the UI.
public class A{
// Holds all the facebook related information here.
public void fetchLikes(){
mAsyncRunner.request( "me/likes", new RequestListener() {
@Override
public void onComplete(String response, Object arg1) {
//update the liked pages to database here.
}
}
}
}
public class B{
public void afterLogin(){
A a = new A();
a.fetchLikes(); // Problem is after here.
updateUI();
}
public void updateUI(){
//updating UI here
}
}
As the facebook fetching is done on its own facebook async runner.I could not make a solution to send a notification back to the caller.
In above case after calling the a.fetchLikes(), it is updating my local DB. But before the process is completed updateUI() is getting called and trying to update my activity.
Please guys, could you offer a way to solve this problem. I need something to notify me after the process is done.
Thanks,
Vijay
It looks like you want to call
updateUI()from theonComplete()handler of theAsyncRunner, (AssumingonComplete()is called from the UI thread. I am not familiar with Facebook’sAsyncRunnerclass.)I would accomplish this by making
fetchLikes()take in some interface, from which I could pass in a call toupdateUI().Then, you can just create an anonymous inner class in
Bto call toupdateUI().