FacebookSDK for Android: How to store the GraphObject from a Response as a member variable for later access

186 views Asked by At

I have declared a class which has the following member variable:

GraphObject myFeed;

Within that class, I am working with the OnCreate(Bundle) method:

@Override
protected void onCreate(Bundle savedInstanceState)

I have the following snippet of code inside this method, to pull from the news feed (the session has already been set up properly):

     Request request = new Request(session,
        "/fql",                         
        params,                         
        HttpMethod.GET,                 
        new Request.Callback(){         
            public void onCompleted(Response response) {
                // issue is here - myFeed is not actually updated to store the 
                // GraphObject returned by response.getGraphObject...
                myFeed = response.getGraphObject();
            }                
    }); 

I'm wondering how I could modify my code to store this GraphObject somehow in my class so that I can access it at some later point (and not just within the scope of the onCompleted method)?

I tried saving it to a member variable (myFeed) inside my class, but since I am performing the assignment inside a parameter that I am setting up, the changes are not propagated through to the member variable.

Thanks in advance!

1

There are 1 answers

0
Samuel Barbosa On

Did the IDE asked you to transform myFeed into a Final member?

Why don't you create a method to call with GraphObejct as argument and inside this method do you assign the value to a class member?