Skip to content
This repository has been archived by the owner on Aug 3, 2019. It is now read-only.

Listener not called #178

Open
xabio opened this issue Jun 13, 2014 · 2 comments
Open

Listener not called #178

xabio opened this issue Jun 13, 2014 · 2 comments
Labels

Comments

@xabio
Copy link

xabio commented Jun 13, 2014

Hi, i am calling
Properties properties = new Properties.Builder().add(Properties.INSTALLED).add(Properties.NAME).add(Properties.PICTURE).build();
mSimpleFacebook.getFriends(properties,onFriendListener);

and i have set
@OverRide
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mSimpleFacebook.onActivityResult(this, requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
as it is said in documentation.

But i don´t get the answer until i unlock the screen and reunlock it. is then when i get the answer.What i am doing wrong? Thanks!!

@sromku
Copy link
Owner

sromku commented Jun 16, 2014

Have you tried to run the sample app?
The how to set sample app: https://github.com/sromku/android-simple-facebook/wiki/Sample-App
Let me know if sample app works for you or you still experiencing the same problem,

@xabio
Copy link
Author

xabio commented Jun 17, 2014

Hi there!
The problem was in void runRequest(Request request) on GetAction class.
The code was task.execute(). If you are running other asynctasks at the same time,the simplefacebook library will fail (as only one thread is allowed to run async tasks)
The solution was to change the method to the following:

   @SuppressLint("NewApi")
void runRequest(Request request) {
    OnActionListener<T> actionListener = getActionListener();
    request.setCallback(mCallback);
    RequestAsyncTask task = new RequestAsyncTask(request);
    if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) {
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }else {
        task.execute();
    }

    if (actionListener != null) {
        actionListener.onThinking();
    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants