Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FacebookSDK Request.newMeRequest never been called

I've got a problem - I'm developing an app with facebook login and also I need to get User data, for somewhat reason I cant receive this data in Request.newMeRequest, because its onCompleted method never been called. I see in logcat only Logged in/out messages. What I'm doing wrong?

Here is my code:

private Session.StatusCallback statusCallback = new Session.StatusCallback() {
    @Override
    public void call(Session session, SessionState state, Exception exception) {
        onSessionStateChange(session, state, exception);
    }
};

private void onSessionStateChange(Session session, SessionState state, Exception exception) {
    if (state.isOpened()) {
        Log.i("QWE", "Logged in...");
        Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user, Response response) {
                Log.i("QWE","onCompleted");
                if (user != null) {
                    Log.i("QWE", "User is "+ user.getUsername());
                }
            }
        });
    } else if (state.isClosed()) {
        Log.i("QWE", "Logged out...");
    }
}
like image 435
whizzzkey Avatar asked Nov 28 '22 07:11

whizzzkey


1 Answers

The problem here is that you've created a request, but you're not calling executeAsync on it, so the request is never made. Try:

Request.newMeRequest(session, new Request.GraphUserCallback() {
    @Override
    public void onCompleted(GraphUser user, Response response) {
        Log.i("QWE","onCompleted");
        if (user != null) {
            Log.i("QWE", "User is "+ user.getUsername());
        }
    }
}).executeAsync();  // <--- CHANGE IS HERE
like image 192
Ming Li Avatar answered Dec 06 '22 18:12

Ming Li