Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session.StatusCallback cannot be resolved to a type - Facebook API

I followed the login authentication tutorial on Facebook and have copied the following code into my android application

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

However, it is giving me the following errors:

Session.StatusCallback cannot be resolved to a type

Which is leading to the following errors:

callback cannot be resolved to a variable

There's also other places where Facebook API calls are made that are giving me errors, but it's not in all the Facebook API calls. Another place I'm getting an error is the following:

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();

where it does not recognize Request.GraphUserCallback, and then executeAsync(). I get the following errors:

Request.GraphUserCallback cannot be resolved to a type
The method executeAsync() is undefined for the type DownloadManager.Request

Does anyone have any advice as to how to fix this?

Thank you for your help in advance!!

like image 756
Rucha Heda Avatar asked Nov 29 '22 01:11

Rucha Heda


2 Answers

I had the same problem as your first one, and I solved it by removing

import android.service.textservice.SpellCheckerService.Session;

and adding

import com.facebook.Session;
like image 81
user2688443 Avatar answered Dec 09 '22 08:12

user2688443


I had a similar issue, and the problem was that I had these two imports in the file

import android.app.DownloadManager.Request;
import android.service.textservice.SpellCheckerService.Session;

And those Request and Session modules were overriding

com.facebook.Session
com.facebook.Request

I actually just removed the two android imports and everything worked nicely. They didn't seem to be used, but eclipse added them in for some strange reason.

Judging by your output

The method executeAsync() is undefined for the type DownloadManager.Request

I'd say it sounds like you have the same imports happening somewhere and they're overriding the facebook imports.

like image 38
wallacer Avatar answered Dec 09 '22 08:12

wallacer