Session.StatusCallback无法解析为某种类型--Facebook API

Ruc*_*eda 4 eclipse android facebook facebook-authentication facebook-android-sdk

我按照Facebook上的登录验证教程,将以下代码复制到我的Android应用程序中

private Session.StatusCallback callback = 
    new Session.StatusCallback()
{
    @Override
    public void call(Session session, 
            SessionState state, Exception exception) {
        onSessionStateChange(session, state, exception);
    }
};
Run Code Online (Sandbox Code Playgroud)

但是,它给了我以下错误:

Session.StatusCallback cannot be resolved to a type
Run Code Online (Sandbox Code Playgroud)

这导致以下错误:

callback cannot be resolved to a variable
Run Code Online (Sandbox Code Playgroud)

Facebook API调用的其他地方也给我带来了错误,但并不是所有的Facebook API调用.另一个我收到错误的地方如下:

Request request = Request.newMeRequest(session, 
                    new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser user, Response response) {
                    // If the response is successful
                    if (session == Session.getActiveSession()) {
                        if (user != null) {
                            // Set the id for the ProfilePictureView
                            // view that in turn displays the profile picture.
                            Log.d("MainActivity", "onComplete() User logged in");
                            parent.owner = MainKickback.userConnection.add(new User(user.getId()));

                            EventFragment e = (EventFragment) fragments[UPCOMING_EVENTS];
                            e.populateEvents();
                        }
                    }
                    if (response.getError() != null) {
                        // Handle errors, will do so later.
                    }
                }
            });
            request.executeAsync();
Run Code Online (Sandbox Code Playgroud)

它不识别Request.GraphUserCallback,然后执行executeAsync().我收到以下错误:

Request.GraphUserCallback cannot be resolved to a type
The method executeAsync() is undefined for the type DownloadManager.Request
Run Code Online (Sandbox Code Playgroud)

有没有人对如何解决这个问题有任何建议?

提前谢谢你的帮助!!

小智 17

我和你的第一个问题有同样的问题,我通过删除来解决它

import android.service.textservice.SpellCheckerService.Session;
Run Code Online (Sandbox Code Playgroud)

并添加

import com.facebook.Session;
Run Code Online (Sandbox Code Playgroud)