Java/Android: Calling Facebook Object from inside a Global Functions file
<p>I am new to Java programing but trying to convert and standardize some code in an application I had developed by calling functions to preform tasks instead of having the same code listed multiple times in multiple locations.</p>

<p>In doing so, I can't seem to figure out how to pull the data and return the results. Below is the code I currently have, but in the RequestListener I am not sure how to return the output?</p>

<h2>MY CODE</h2>

<pre><code>public class GlobalFacebook {
    public static void loadFriends()    {
        Log.i("GlobalFacebook", "Starting to loadFacebookFriends");
        AsyncFacebookRunner asybcTastRun;
        asybcTastRun = new AsyncFacebookRunner(GlobalSettings.facebookObj);
        asybcTastRun.request("me/friends", FriendCallback());
    }

    private static RequestListener FriendCallback() {
        // TODO Auto-generated method stub
        // ***** How to return the RESPONSE? *****
        json=new JSONObject(jsonData);
        JSONArray friend_item = json.getJSONArray("data");
        for(int loop=0;loop &lt; friend_item.length();loop++)  {
            JSONObject friend = friend_item.getJSONObject(loop);

            String friendID = friend.getString("id");
            String friendName = friend.getString("name");
        }       
        return null;
    }
}
</code></pre>

<p>Below is the original code, but when I try and copy it to my functions I get the error "The method FriendCallback() is undefined for the type GlobalFacebook".</p>

<h2>ORIGINAL CODE</h2>

<pre><code>public void loadFriends()   {
    asybcTastRun = new AsyncFacebookRunner(GlobalSettings.facebookObj);
    asybcTastRun.request("me/friends", new FriendCallback());
}

//----------------get the response of the facebook server
public class FriendCallback implements AsyncFacebookRunner.RequestListener
{
    public void onComplete(final String response, Object state) {
        // TODO Auto-generated method stub
        json=new JSONObject(response);
        JSONArray friend_item = json.getJSONArray("data");
        for(int loop=0;loop &lt; friend_item.length();loop++)  {
            JSONObject friend = friend_item.getJSONObject(loop);

            String friendID = friend.getString("id");
            String friendName = friend.getString("name");
        }       
        return null;
    }

    public void onIOException(IOException e, Object state) {
        // TODO Auto-generated method stub
        Log.e("StartDevice","io error "+e.toString());
    }

    public void onFileNotFoundException(FileNotFoundException e,
            Object state) {
        // TODO Auto-generated method stub
        Log.e("StartDevice"," file error "+e.toString());
    }

    public void onMalformedURLException(MalformedURLException e,
            Object state) {
        // TODO Auto-generated method stub
        Log.e("StartDevice","url  error "+e.toString());
    }

    public void onFacebookError(FacebookError e, Object state) {
        // TODO Auto-generated method stub
        Log.e("StartDevice"," face book error "+e.toString());
    }

}
</code></pre>
