本文介绍了FacebookSDK Request.newMeRequest从来没有被称为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题 - 我正在开发与Facebook登录的应用程序,我也需要得到用户的数据,有些原因我不能收到Request.newMeRequest这个数据,因为它的onCompleted方法不会被调用。我在logcat中看到的只有登录/退出的消息。我做错了什么?

下面是我的code:

 私人Session.StatusCallback statusCallback =新Session.StatusCallback(){
    @覆盖
    公共无效呼叫(会话的会话,SessionState会状态,例外的例外){
        onSessionStateChange(会话,状态除外);
    }
};

私人无效onSessionStateChange(会话的会话,SessionState会状态,例外的例外){
    如果(state.isOpened()){
        Log.i(QWE,已登录......);
        Request.newMeRequest(会话,新Request.GraphUserCallback(){
            @覆盖
            公共无效onCompleted(GraphUser用户,响应响应){
                Log.i(QWE,onCompleted);
                如果(用户!= NULL){
                    Log.i(QWE,用户为+ user.getUsername());
                }
            }
        });
    }否则如果(state.isClosed()){
        Log.i(QWE,注销...);
    }
}
 

解决方案

这里的问题是,你已经创建了一个请求,但你不能在它调用executeAsync,因此请求从未。尝试:

  Request.newMeRequest(会话,新Request.GraphUserCallback(){
    @覆盖
    公共无效onCompleted(GraphUser用户,响应响应){
        Log.i(QWE,onCompleted);
        如果(用户!= NULL){
            Log.i(QWE,用户为+ user.getUsername());
        }
    }
})executeAsync()。 //< --- CHANGE IS HERE
 

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...");
    }
}
解决方案

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

这篇关于FacebookSDK Request.newMeRequest从来没有被称为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-22 13:15